- fix some bug on client/server network (by Joe)

git-svn-id: https://svn.code.sf.net/p/speed-dreams/code/trunk@9051 30fe4595-0a0c-4342-8851-515496e4dcbd

Former-commit-id: 28d79602361274d7b9ccab1c0118b7399ff3c128
Former-commit-id: d257ff3fb15f83681b5162f0ef6de1d8ebad6698
This commit is contained in:
torcs-ng 2023-06-27 10:35:07 +00:00
parent 5a26758c92
commit b13005689c
3 changed files with 37 additions and 9 deletions

View file

@ -179,6 +179,8 @@ NetDriver::NetDriver()
//Initialize values
idx = -1;
memset(name, 0, sizeof(name));
memset(sname, 0, sizeof(sname));
memset(cname, 0, sizeof(cname));
memset(car, 0, sizeof(car));
memset(team, 0, sizeof(team));
memset(author, 0, sizeof(author));
@ -188,6 +190,7 @@ NetDriver::NetDriver()
green = 1.0;
blue = 1.0;
client = false;
active = false;
memset(module, 0, sizeof(module));
memset(type, 0, sizeof(type));
connectionID = 0;
@ -264,7 +267,9 @@ int NetNetwork::GetNetworkHumanIdx()
char buf[255];
sprintf(buf,"drivers/networkhuman/networkhuman.xml");
void *params = GfParmReadFileLocal(buf,GFPARM_RMODE_REREAD);
assert(params);
if(params)
{
char path2[256];
int i=0;
@ -283,6 +288,11 @@ int NetNetwork::GetNetworkHumanIdx()
while(pName);
GfParmReleaseHandle(params);
}
else
{
GfLogError("Unable to parse file %s\n", buf);
}
return idx;
}

View file

@ -130,8 +130,26 @@ bool LegacyMenu::startRace()
// Configure the new race (but don't enter the config. menu tree).
LmRaceEngine().configureRace(/* bInteractive */ false);
// Start the race engine state automaton
LmRaceEngine().startNewRace();
#ifdef CLIENT_SERVER
std::string racID = pSelRaceMan->getId();
if ((0 == strcmp(racID.c_str(), "netserver")))
{
::RmNetworkHostMenu();
}
else if ((0 == strcmp(racID.c_str(), "netwatcher")))
{
// TODO netwatcher menu may be RmNetworkClientMenu()
// with no driver ??
::RmNetworkClientMenu();
}
else if ((0 == strcmp(racID.c_str(), "netclient")))
{
::RmNetworkClientMenu();
}
else
#endif
// Start the race engine state automaton
LmRaceEngine().startNewRace();
}
else
{

View file

@ -1133,12 +1133,12 @@ GetHumanDriver(NetDriver &driver,int index)
if (GfParmExistsSection(params, path2) == 0) return 0;
memcpy(driver.name, GfParmGetStr(params, path2, "name", NULL), sizeof(driver.name));
memcpy(driver.sname, GfParmGetStr(params, path2, "short name", NULL), sizeof(driver.sname));
memcpy(driver.cname, GfParmGetStr(params, path2, "code name", NULL), sizeof(driver.cname));
memcpy(driver.car,GfParmGetStr(params, path2, "car name", NULL), sizeof(driver.car));
memcpy(driver.type,GfParmGetStr(params, path2, "type", NULL), sizeof(driver.type));
memcpy(driver.skilllevel,GfParmGetStr(params, path2, "skill level", NULL), sizeof(driver.skilllevel));
strncpy(driver.name, GfParmGetStr(params, path2, "name", NULL), sizeof(driver.name) - 1);
strncpy(driver.sname, GfParmGetStr(params, path2, "short name", NULL), sizeof(driver.sname) - 1);
strncpy(driver.cname, GfParmGetStr(params, path2, "code name", NULL), sizeof(driver.cname) - 1);
strncpy(driver.car,GfParmGetStr(params, path2, "car name", NULL), sizeof(driver.car) - 1);
strncpy(driver.type,GfParmGetStr(params, path2, "type", NULL), sizeof(driver.type) - 1);
strncpy(driver.skilllevel,GfParmGetStr(params, path2, "skill level", NULL), sizeof(driver.skilllevel) - 1);
driver.racenumber = GfParmGetNum(params, path2, "race number",NULL,1.0);
driver.red = GfParmGetNum(params, path2, "red",NULL,1.0);