[+] Added Opponents field in CServerSetup
This commit is contained in:
parent
d06e4a584a
commit
75bf724a78
4 changed files with 9 additions and 2 deletions
src
|
@ -75,7 +75,7 @@ public:
|
|||
CServerSetup() { Clear(); }
|
||||
size_t Serialize(unsigned char *p) const;
|
||||
size_t Deserialize(const unsigned char *p);
|
||||
static size_t Size() { return 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 * PlayerMax + 1 * PlayerMax + 1 * PlayerMax; }
|
||||
static size_t Size() { return 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 * PlayerMax + 1 * PlayerMax + 1 * PlayerMax; }
|
||||
void Clear();
|
||||
|
||||
bool operator == (const CServerSetup &rhs) const;
|
||||
|
@ -89,6 +89,7 @@ public:
|
|||
uint8_t GameTypeOption; /// Game type option
|
||||
uint8_t Difficulty; /// Difficulty option
|
||||
uint8_t MapRichness; /// Map richness option
|
||||
uint8_t Opponents; /// Number of AI opponents
|
||||
uint8_t CompOpt[PlayerMax]; /// Free slot option selection {"Available", "Computer", "Closed" }
|
||||
uint8_t Ready[PlayerMax]; /// Client ready state
|
||||
uint8_t Race[PlayerMax]; /// Client race selection
|
||||
|
|
|
@ -229,6 +229,7 @@ size_t CServerSetup::Serialize(unsigned char *buf) const
|
|||
p += serialize8(p, this->GameTypeOption);
|
||||
p += serialize8(p, this->Difficulty);
|
||||
p += serialize8(p, this->MapRichness);
|
||||
p += serialize8(p, this->Opponents);
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
p += serialize8(p, this->CompOpt[i]);
|
||||
}
|
||||
|
@ -252,6 +253,7 @@ size_t CServerSetup::Deserialize(const unsigned char *p)
|
|||
p += deserialize8(p, &this->GameTypeOption);
|
||||
p += deserialize8(p, &this->Difficulty);
|
||||
p += deserialize8(p, &this->MapRichness);
|
||||
p += deserialize8(p, &this->Opponents);
|
||||
for (int i = 0; i < PlayerMax; ++i) {
|
||||
p += deserialize8(p, &this->CompOpt[i]);
|
||||
}
|
||||
|
@ -274,6 +276,7 @@ void CServerSetup::Clear()
|
|||
GameTypeOption = 0;
|
||||
Difficulty = 0;
|
||||
MapRichness = 0;
|
||||
Opponents = 0;
|
||||
memset(CompOpt, 0, sizeof(CompOpt));
|
||||
memset(Ready, 0, sizeof(Ready));
|
||||
memset(Race, 0, sizeof(Race));
|
||||
|
@ -289,6 +292,7 @@ bool CServerSetup::operator == (const CServerSetup &rhs) const
|
|||
&& GameTypeOption == rhs.GameTypeOption
|
||||
&& Difficulty == rhs.Difficulty
|
||||
&& MapRichness == rhs.MapRichness
|
||||
&& Opponents == rhs.Opponents
|
||||
&& memcmp(CompOpt, rhs.CompOpt, sizeof(CompOpt)) == 0
|
||||
&& memcmp(Ready, rhs.Ready, sizeof(Ready)) == 0
|
||||
&& memcmp(Race, rhs.Race, sizeof(Race)) == 0);
|
||||
|
|
|
@ -1532,10 +1532,11 @@ void NetworkServerStartGame()
|
|||
|
||||
// Calculate NetPlayers
|
||||
NetPlayers = h;
|
||||
int compPlayers = ServerSetupState.Opponents;
|
||||
for (int i = 1; i < h; ++i) {
|
||||
if (Hosts[i].PlyNr == 0 && ServerSetupState.CompOpt[i] != 0) {
|
||||
NetPlayers--;
|
||||
} else if (Hosts[i].PlyName[0] == 0) {
|
||||
} else if (Hosts[i].PlyName[0] == 0 && --compPlayers >= 0) {
|
||||
// Unused slot gets a computer player
|
||||
ServerSetupState.CompOpt[i] = 1;
|
||||
LocalSetupState.CompOpt[i] = 1;
|
||||
|
|
|
@ -22,6 +22,7 @@ class CServerSetup {
|
|||
unsigned char GameTypeOption;
|
||||
unsigned char Difficulty;
|
||||
unsigned char MapRichness;
|
||||
unsigned char Opponents;
|
||||
unsigned short CompOpt[PlayerMax]; // cannot use char since tolua interpret variable as string else.
|
||||
unsigned short Ready[PlayerMax]; // cannot use char since tolua interpret variable as string else.
|
||||
unsigned short Race[PlayerMax]; // cannot use char since tolua interpret variable as string else.
|
||||
|
|
Loading…
Add table
Reference in a new issue