Skip to content

Commit abc99dd

Browse files
committed
more game config; game speed
1 parent e748896 commit abc99dd

File tree

10 files changed

+50
-36
lines changed

10 files changed

+50
-36
lines changed

c/uwapi/uwapi/modules/botsAdmin.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ extern "C"
1818
UNNATURAL_API uint16 uwGetServerPort(void);
1919
UNNATURAL_API void uwAdminSetMapSelection(const char *path);
2020
UNNATURAL_API void uwAdminSetGameConfig(const UwGameConfig *config);
21-
UNNATURAL_API void uwAdminSetGameSpeed(float speed);
22-
UNNATURAL_API void uwAdminSetWeatherSpeed(float speed, float offset);
2321
UNNATURAL_API void uwAdminStartGame(void);
2422
UNNATURAL_API void uwAdminTerminateGame(void);
2523
UNNATURAL_API void uwAdminPauseGame(bool pause);

c/uwapi/uwapi/modules/common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ extern "C"
3434
typedef uint64_t uint64;
3535
typedef int64_t sint64;
3636

37-
static const uint32 UW_VERSION = 45;
37+
static const uint32 UW_VERSION = 46;
3838
static const uint32 UW_GameTicksPerSecond = 20;
3939

4040
typedef struct UwIds

c/uwapi/uwapi/modules/game.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ extern "C"
1818
{
1919
bool ranked;
2020
bool diplomacy;
21+
bool lockedSpeed;
22+
bool cheats;
2123
} UwGameConfig;
2224

2325
UNNATURAL_API void uwGameConfig(UwGameConfig *config);
2426

27+
UNNATURAL_API void uwSetGameSpeed(float speed);
28+
UNNATURAL_API void uwSetWeatherSpeed(float speed, float offset);
29+
2530
// game state
2631

2732
typedef enum UwGameStateEnum

csharp/uwapi/admin.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ public static void SetMapSelection(string path)
2525
Interop.uwAdminSetMapSelection(path);
2626
}
2727

28-
public static void SetGameSpeed(float speed)
29-
{
30-
Interop.uwAdminSetGameSpeed(speed);
31-
}
32-
33-
public static void SetWeatherSpeed(float speed, float offset)
34-
{
35-
Interop.uwAdminSetWeatherSpeed(speed, offset);
36-
}
37-
3828
public static void StartGame()
3929
{
4030
Interop.uwAdminStartGame();

csharp/uwapi/game.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ public static uint GameTick()
108108
return Interop.uwGameTick();
109109
}
110110

111+
public static void SetGameSpeed(float speed)
112+
{
113+
Interop.uwSetGameSpeed(speed);
114+
}
115+
116+
public static void SetWeatherSpeed(float speed, float offset)
117+
{
118+
Interop.uwSetWeatherSpeed(speed, offset);
119+
}
120+
111121
public static MapStateEnum MapState()
112122
{
113123
return Interop.uwMapState();

csharp/uwapi/interop.cs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,6 @@ public static class Interop
3232
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
3333
public static extern void uwAdminSetGameConfig(ref UwGameConfig config);
3434

35-
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
36-
public static extern void uwAdminSetGameSpeed(float speed);
37-
38-
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
39-
public static extern void uwAdminSetWeatherSpeed(float speed, float offset);
40-
4135
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
4236
public static extern void uwAdminStartGame();
4337

@@ -326,7 +320,7 @@ public static extern void uwCommandPlaceConstruction(uint constructionProto, uin
326320
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
327321
public static extern void uwCommandSelfDestruct(uint entityId);
328322

329-
public const uint UW_VERSION = 45;
323+
public const uint UW_VERSION = 46;
330324
public const uint UW_GameTicksPerSecond = 20;
331325
[StructLayout(LayoutKind.Sequential)]
332326
public struct UwIds
@@ -699,11 +693,21 @@ public struct UwGameConfig
699693
public bool ranked;
700694
[MarshalAs(UnmanagedType.I1)]
701695
public bool diplomacy;
696+
[MarshalAs(UnmanagedType.I1)]
697+
public bool lockedSpeed;
698+
[MarshalAs(UnmanagedType.I1)]
699+
public bool cheats;
702700
}
703701

704702
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
705703
public static extern void uwGameConfig(ref UwGameConfig config);
706704

705+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
706+
public static extern void uwSetGameSpeed(float speed);
707+
708+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
709+
public static extern void uwSetWeatherSpeed(float speed, float offset);
710+
707711
public enum UwGameStateEnum
708712
{
709713
None = 0,

python/uwapi/admin.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,6 @@ def start_game(self) -> None:
2727
def terminate_game(self) -> None:
2828
uw_interop.uwAdminTerminateGame()
2929

30-
def set_game_speed(self, speed: float) -> None:
31-
uw_interop.uwAdminSetGameSpeed(speed)
32-
33-
def set_weather_speed(self, speed: float, offset: float) -> None:
34-
uw_interop.uwAdminSetWeatherSpeed(speed, offset)
35-
3630
def add_ai(self, intendedRace: int = 0, difficulty: float = 0) -> None:
3731
uw_interop.uwAdminAddAi(intendedRace, difficulty)
3832

python/uwapi/bots.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ typedef int32_t sint32;
99
typedef uint64_t uint64;
1010
typedef int64_t sint64;
1111

12-
static const uint32 UW_VERSION = 45;
12+
static const uint32 UW_VERSION = 46;
1313
static const uint32 UW_GameTicksPerSecond = 20;
1414

1515
typedef struct UwIds
@@ -74,8 +74,6 @@ uint64 uwGetUserId(void);
7474
uint16 uwGetServerPort(void);
7575
void uwAdminSetMapSelection(const char *path);
7676
void uwAdminSetGameConfig(const UwGameConfig *config);
77-
void uwAdminSetGameSpeed(float speed);
78-
void uwAdminSetWeatherSpeed(float speed, float offset);
7977
void uwAdminStartGame(void);
8078
void uwAdminTerminateGame(void);
8179
void uwAdminPauseGame(bool pause);
@@ -425,10 +423,15 @@ typedef struct UwGameConfig
425423
{
426424
bool ranked;
427425
bool diplomacy;
426+
bool lockedSpeed;
427+
bool cheats;
428428
} UwGameConfig;
429429

430430
void uwGameConfig(UwGameConfig *config);
431431

432+
void uwSetGameSpeed(float speed);
433+
void uwSetWeatherSpeed(float speed, float offset);
434+
432435
typedef enum UwGameStateEnum
433436
{
434437
UwGameStateEnum_None = 0,

python/uwapi/game.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def map_state(self) -> UwMapStateEnum:
7979
def game_config(self) -> UwGameConfig:
8080
return uw_interop.uwGameConfig()
8181

82+
def set_game_speed(self, speed: float) -> None:
83+
uw_interop.uwSetGameSpeed(speed)
84+
85+
def set_weather_speed(self, speed: float, offset: float) -> None:
86+
uw_interop.uwSetWeatherSpeed(speed, offset)
87+
8288
def performance_statistics(self) -> UwPerformanceStatistics:
8389
return uw_interop.uwPerformanceStatistics()
8490

python/uwapi/interop.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,8 @@ class UwDiplomacyProposalComponent:
321321
class UwGameConfig:
322322
ranked: bool
323323
diplomacy: bool
324+
lockedSpeed: bool
325+
cheats: bool
324326

325327
@dataclass
326328
class UwShootingsArray:
@@ -530,12 +532,6 @@ def uwAdminSetGameConfig(self, config: UwGameConfig) -> None:
530532
config_ = self._UwGameConfig_pytoc(config)
531533
self._api.uwAdminSetGameConfig(config_)
532534

533-
def uwAdminSetGameSpeed(self, speed: float) -> None:
534-
self._api.uwAdminSetGameSpeed(speed)
535-
536-
def uwAdminSetWeatherSpeed(self, speed: float, offset: float) -> None:
537-
self._api.uwAdminSetWeatherSpeed(speed, offset)
538-
539535
def uwAdminStartGame(self) -> None:
540536
self._api.uwAdminStartGame()
541537

@@ -949,6 +945,12 @@ def uwGameConfig(self) -> UwGameConfig:
949945
config_ = self._UwGameConfig_ctopy(config)
950946
return config_
951947

948+
def uwSetGameSpeed(self, speed: float) -> None:
949+
self._api.uwSetGameSpeed(speed)
950+
951+
def uwSetWeatherSpeed(self, speed: float, offset: float) -> None:
952+
self._api.uwSetWeatherSpeed(speed, offset)
953+
952954
def uwSetGameStateCallback(self, callback: UwGameStateCallbackType) -> None:
953955
@self._ffi.callback("UwGameStateCallbackType")
954956
def c_callback(state):
@@ -1318,12 +1320,14 @@ def _UwDiplomacyProposalComponent_ctopy(self, val) -> UwDiplomacyProposalCompone
13181320
return UwDiplomacyProposalComponent(int(val.offeror), int(val.offeree), UwForeignPolicyEnum(val.proposal))
13191321

13201322
def _UwGameConfig_ctopy(self, val) -> UwGameConfig:
1321-
return UwGameConfig(bool(val.ranked), bool(val.diplomacy))
1323+
return UwGameConfig(bool(val.ranked), bool(val.diplomacy), bool(val.lockedSpeed), bool(val.cheats))
13221324

13231325
def _UwGameConfig_pytoc(self, val: UwGameConfig):
13241326
r = self._ffi.new("UwGameConfig *")
13251327
r.ranked = val.ranked
13261328
r.diplomacy = val.diplomacy
1329+
r.lockedSpeed = val.lockedSpeed
1330+
r.cheats = val.cheats
13271331
return r
13281332

13291333
def _UwShootingsArray_ctopy(self, val) -> UwShootingsArray:

0 commit comments

Comments
 (0)