Skip to content

Commit efaa3b0

Browse files
committed
diplomacy
1 parent 2b242b3 commit efaa3b0

File tree

12 files changed

+99
-6
lines changed

12 files changed

+99
-6
lines changed

c/uwapi/uwapi/modules/botsAdmin.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,14 @@ extern "C"
1010

1111
#ifdef UNNATURAL_BOTS
1212

13+
typedef struct UwGameConfig UwGameConfig;
1314
typedef struct UwPlayerAiConfigComponent UwPlayerAiConfigComponent;
1415

1516
UNNATURAL_API uint64 uwGetLobbyId(void);
1617
UNNATURAL_API uint64 uwGetUserId(void);
1718
UNNATURAL_API uint16 uwGetServerPort(void);
1819
UNNATURAL_API void uwAdminSetMapSelection(const char *path);
20+
UNNATURAL_API void uwAdminSetGameConfig(const UwGameConfig *config);
1921
UNNATURAL_API void uwAdminSetGameSpeed(float speed);
2022
UNNATURAL_API void uwAdminSetWeatherSpeed(float speed, float offset);
2123
UNNATURAL_API void uwAdminStartGame(void);

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 = 44;
37+
static const uint32 UW_VERSION = 45;
3838
static const uint32 UW_GameTicksPerSecond = 20;
3939

4040
typedef struct UwIds

c/uwapi/uwapi/modules/game.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,16 @@ extern "C"
1212

1313
#endif
1414

15+
// game config
16+
17+
typedef struct UwGameConfig
18+
{
19+
bool ranked;
20+
bool diplomacy;
21+
} UwGameConfig;
22+
23+
UNNATURAL_API void uwGameConfig(UwGameConfig *config);
24+
1525
// game state
1626

1727
typedef enum UwGameStateEnum

c/uwapi/uwapi/modules/world.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ extern "C"
4949
UNNATURAL_API uint32 uwFindConstructionPlacement(uint32 constructionProto, uint32 position, uint32 owner, uint32 recipeProto); // recipeProto may be 0
5050
#endif
5151

52+
#ifdef UNNATURAL_BOTS
53+
UNNATURAL_API void uwOfferForeignPolicy(uint32 forceId, UwForeignPolicyEnum policy);
54+
#endif
55+
5256
// overview
5357

5458
typedef enum UwOverviewFlags

csharp/uwapi/game.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,13 @@ public static MapStateEnum MapState()
113113
return Interop.uwMapState();
114114
}
115115

116+
public static Interop.UwGameConfig GameConfig()
117+
{
118+
Interop.UwGameConfig data = new Interop.UwGameConfig();
119+
Interop.uwGameConfig(ref data);
120+
return data;
121+
}
122+
116123
public static Interop.UwPerformanceStatistics PerformanceStatistics()
117124
{
118125
Interop.UwPerformanceStatistics data = new Interop.UwPerformanceStatistics();

csharp/uwapi/interop.cs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ public static class Interop
2929
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
3030
public static extern void uwAdminSetMapSelection([MarshalAs(UnmanagedType.LPStr)] string path);
3131

32+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
33+
public static extern void uwAdminSetGameConfig(ref UwGameConfig config);
34+
3235
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
3336
public static extern void uwAdminSetGameSpeed(float speed);
3437

@@ -323,7 +326,7 @@ public static extern void uwCommandPlaceConstruction(uint constructionProto, uin
323326
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
324327
public static extern void uwCommandSelfDestruct(uint entityId);
325328

326-
public const uint UW_VERSION = 44;
329+
public const uint UW_VERSION = 45;
327330
public const uint UW_GameTicksPerSecond = 20;
328331
[StructLayout(LayoutKind.Sequential)]
329332
public struct UwIds
@@ -689,6 +692,18 @@ public struct UwDiplomacyProposalComponent
689692
public static extern bool uwFetchDiplomacyProposalComponent(IntPtr entity,
690693
ref UwDiplomacyProposalComponent data);
691694

695+
[StructLayout(LayoutKind.Sequential)]
696+
public struct UwGameConfig
697+
{
698+
[MarshalAs(UnmanagedType.I1)]
699+
public bool ranked;
700+
[MarshalAs(UnmanagedType.I1)]
701+
public bool diplomacy;
702+
}
703+
704+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
705+
public static extern void uwGameConfig(ref UwGameConfig config);
706+
692707
public enum UwGameStateEnum
693708
{
694709
None = 0,
@@ -973,6 +988,9 @@ public struct UwUnitUpgrades
973988
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
974989
public static extern uint uwFindConstructionPlacement(uint constructionProto, uint position, uint recipeProto);
975990

991+
[DllImport(LibName, CallingConvention = CallingConvention.Cdecl)]
992+
public static extern void uwOfferForeignPolicy(uint forceId, UwForeignPolicyEnum policy);
993+
976994
[Flags]
977995
public enum UwOverviewFlags
978996
{

csharp/uwapi/world.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,15 @@ public static Entity Entity(uint id)
113113
return entities[id];
114114
}
115115

116-
public static PolicyEnum Policy(uint force)
116+
public static PolicyEnum Policy(uint forceId)
117117
{
118118
PolicyEnum val;
119-
return policies.TryGetValue(force, out val) ? val : PolicyEnum.None;
119+
return policies.TryGetValue(forceId, out val) ? val : PolicyEnum.None;
120+
}
121+
122+
public static void OfferForeignPolicy(uint forceId, PolicyEnum policy)
123+
{
124+
Interop.uwOfferForeignPolicy(forceId, policy);
120125
}
121126

122127
static Interop.UwMyPlayer myPlayer;

python/uwapi/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@
1313
from .prototypes import uw_prototypes
1414
from .world import uw_world
1515

16-
__all__ = ["uw_admin","uw_commands","Entity","INVALID","uw_events","uw_game","UwapiLibrary","uw_map","uw_prototypes","uw_world","Severity","LogCallback","ConnectionState","MyPlayer","AssistConfig","PerformanceStatistics","OrderType","OrderPriority","Order","Orders","Ids","Priority","Ping","PathState","ForeignPolicy","ChatTarget","ProtoComponent","OwnerComponent","ControllerComponent","PositionComponent","UnitState","UnitComponent","LifeComponent","ManaComponent","MoveComponent","AimComponent","RecipeComponent","RecipeStatisticsComponent","LogisticsTimestampComponent","PriorityComponent","AmountComponent","AttachmentComponent","PingComponent","PlayerState","PlayerConnectionClass","PlayerComponent","PlayerAiConfigComponent","ForceState","ForceComponent","ForceDetailsComponent","ForeignPolicyComponent","DiplomacyProposalComponent","GameState","ShootingEvent","ShootingsArray","TaskType","MapState","MapInfo","MapStartingPosition","MapStartingPositionsArray","Tile","Cluster","ClustersDistancesQuery","ClustersDistancesResult","PrototypeType","MyForceStatistics","UnitUpgrades","Overview","OverviewExtract","UnitPathfindingQuery","UnitPathfindingResult"]
16+
__all__ = ["uw_admin","uw_commands","Entity","INVALID","uw_events","uw_game","UwapiLibrary","uw_map","uw_prototypes","uw_world","Severity","LogCallback","ConnectionState","MyPlayer","AssistConfig","PerformanceStatistics","OrderType","OrderPriority","Order","Orders","Ids","Priority","Ping","PathState","ForeignPolicy","ChatTarget","ProtoComponent","OwnerComponent","ControllerComponent","PositionComponent","UnitState","UnitComponent","LifeComponent","ManaComponent","MoveComponent","AimComponent","RecipeComponent","RecipeStatisticsComponent","LogisticsTimestampComponent","PriorityComponent","AmountComponent","AttachmentComponent","PingComponent","PlayerState","PlayerConnectionClass","PlayerComponent","PlayerAiConfigComponent","ForceState","ForceComponent","ForceDetailsComponent","ForeignPolicyComponent","DiplomacyProposalComponent","GameConfig","GameState","ShootingEvent","ShootingsArray","TaskType","MapState","MapInfo","MapStartingPosition","MapStartingPositionsArray","Tile","Cluster","ClustersDistancesQuery","ClustersDistancesResult","PrototypeType","MyForceStatistics","UnitUpgrades","Overview","OverviewExtract","UnitPathfindingQuery","UnitPathfindingResult"]

python/uwapi/bots.h

Lines changed: 13 additions & 1 deletion
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 = 44;
12+
static const uint32 UW_VERSION = 45;
1313
static const uint32 UW_GameTicksPerSecond = 20;
1414

1515
typedef struct UwIds
@@ -66,12 +66,14 @@ typedef enum UwChatTargetEnum
6666
UwChatTargetEnum_Observers = 5,
6767
} UwChatTargetEnum;
6868

69+
typedef struct UwGameConfig UwGameConfig;
6970
typedef struct UwPlayerAiConfigComponent UwPlayerAiConfigComponent;
7071

7172
uint64 uwGetLobbyId(void);
7273
uint64 uwGetUserId(void);
7374
uint16 uwGetServerPort(void);
7475
void uwAdminSetMapSelection(const char *path);
76+
void uwAdminSetGameConfig(const UwGameConfig *config);
7577
void uwAdminSetGameSpeed(float speed);
7678
void uwAdminSetWeatherSpeed(float speed, float offset);
7779
void uwAdminStartGame(void);
@@ -419,6 +421,14 @@ typedef struct UwDiplomacyProposalComponent
419421
UwForeignPolicyEnum proposal;
420422
} UwDiplomacyProposalComponent;
421423
bool uwFetchDiplomacyProposalComponent(UwEntityPtr entity, UwDiplomacyProposalComponent *data);
424+
typedef struct UwGameConfig
425+
{
426+
bool ranked;
427+
bool diplomacy;
428+
} UwGameConfig;
429+
430+
void uwGameConfig(UwGameConfig *config);
431+
422432
typedef enum UwGameStateEnum
423433
{
424434
UwGameStateEnum_None = 0,
@@ -597,6 +607,8 @@ bool uwTestShootingEntities(uint32 shooterId, uint32 targetId);
597607

598608
bool uwTestConstructionPlacement(uint32 constructionProto, uint32 position, uint32 recipeProto);
599609
uint32 uwFindConstructionPlacement(uint32 constructionProto, uint32 position, uint32 recipeProto);
610+
void uwOfferForeignPolicy(uint32 forceId, UwForeignPolicyEnum policy);
611+
600612
typedef enum UwOverviewFlags
601613
{
602614
UwOverviewFlags_None = 0,

python/uwapi/game.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ def game_tick(self) -> int:
7676
def map_state(self) -> UwMapStateEnum:
7777
return uw_interop.uwMapState()
7878

79+
def game_config(self) -> UwGameConfig:
80+
return uw_interop.uwGameConfig()
81+
7982
def performance_statistics(self) -> UwPerformanceStatistics:
8083
return uw_interop.uwPerformanceStatistics()
8184

0 commit comments

Comments
 (0)