- Changed D3DFB to explicitly request double buffering instead of assuming

that the drivers will treat a BackBufferCount of 0 as a request for
  double buffering.
- Fixed: Unsetting a cvar did not remove it from the list of tab
  completions.
- Added "" as a synonym for "nullimage" in SBARINFO.
- Fixed: MAKESAVESIG's stringifier in version.h did not work as expected.
  It stringified the passed macro name, not the value of the macro.
- Moved DCajunMaster off the DObject hierarchy.
- Changed DCajunMaster::getspawned into a TArray of FStrings. It was
  mysteriously being left pointing to uninitialized memory during the
  final GC at exit and crashing.
- Fixed: The code that removed hexdd.wad from the list of IWADs when
  hexen.wad was not present did not work.


SVN r861 (trunk)
This commit is contained in:
Randy Heit 2008-03-28 00:38:17 +00:00
parent 643fc792bd
commit 776d89428d
31 changed files with 17388 additions and 17388 deletions

File diff suppressed because it is too large Load Diff

View File

@ -15,13 +15,6 @@
CVAR (Int, bot_next_color, 11, 0)
CVAR (Bool, bot_observer, false, 0)
IMPLEMENT_POINTY_CLASS (DCajunMaster)
DECLARE_POINTER (getspawned)
DECLARE_POINTER (firstthing)
DECLARE_POINTER (body1)
DECLARE_POINTER (body2)
END_POINTERS
CCMD (addbot)
{
if (gamestate != GS_LEVEL && gamestate != GS_INTERMISSION)
@ -43,12 +36,12 @@ CCMD (addbot)
}
if (argv.argc() > 1)
bglobal->SpawnBot (argv[1]);
bglobal.SpawnBot (argv[1]);
else
bglobal->SpawnBot (NULL);
bglobal.SpawnBot (NULL);
}
void DCajunMaster::ClearPlayer (int i, bool keepTeam)
void FCajunMaster::ClearPlayer (int i, bool keepTeam)
{
if (players[i].mo)
{
@ -92,7 +85,7 @@ CCMD (freeze)
CCMD (listbots)
{
botinfo_t *thebot = bglobal->botinfo;
botinfo_t *thebot = bglobal.botinfo;
int count = 0;
while (thebot)
@ -116,9 +109,6 @@ AT_GAME_SET(BotStuff)
AWeapon * w;
AActor * a;
bglobal = new DCajunMaster;
GC::WriteBarrier(bglobal);
w = (AWeapon*)GetDefaultByName ("Pistol");
if (w != NULL)
{

View File

@ -73,13 +73,10 @@ struct botinfo_t
};
//Used to keep all the globally needed variables in nice order.
class DCajunMaster : public DObject
class FCajunMaster
{
DECLARE_CLASS (DCajunMaster, DObject)
HAS_OBJECT_POINTERS
public:
DCajunMaster();
~DCajunMaster();
~FCajunMaster();
void ClearPlayer (int playernum, bool keepTeam);
@ -110,7 +107,7 @@ public:
void Pitch (AActor *actor, AActor *target);
bool IsDangerous (sector_t *sec);
DArgs *getspawned; //Array of bots (their names) which should be spawned when starting a game.
TArray<FString> getspawned; //Array of bots (their names) which should be spawned when starting a game.
bool botingame[MAXPLAYERS];
BYTE freeze:1; //Game in freeze mode.
BYTE changefreeze:1; //Game wants to change freeze mode.
@ -119,6 +116,8 @@ public:
int spawn_tries;
int wanted_botnum;
TObjPtr<AActor> firstthing;
TObjPtr<AActor> body1;
TObjPtr<AActor> body2;
bool m_Thinking;
@ -142,14 +141,12 @@ protected:
bool ctf;
int loaded_bots;
int t_join;
TObjPtr<AActor> body1;
TObjPtr<AActor> body2;
bool observer; //Consoleplayer is observer.
};
//Externs
extern DCajunMaster *bglobal;
extern FCajunMaster bglobal;
EXTERN_CVAR (Float, bot_flag_return_time)
EXTERN_CVAR (Int, bot_next_color)

View File

@ -63,7 +63,7 @@ static bool PTR_Reachable (intercept_t *in)
fixed_t ceilingheight = s->ceilingplane.ZatPoint (hitx, hity);
fixed_t floorheight = s->floorplane.ZatPoint (hitx, hity);
if (!bglobal->IsDangerous (s) && //Any nukage/lava?
if (!bglobal.IsDangerous (s) && //Any nukage/lava?
(floorheight <= (last_z+MAXMOVEHEIGHT)
&& ((ceilingheight == floorheight && line->special)
|| (ceilingheight - floorheight) >= looker->height))) //Does it fit?
@ -100,7 +100,7 @@ static bool PTR_Reachable (intercept_t *in)
//Checks TRUE reachability from
//one actor to another. First mobj (actor) is looker.
bool DCajunMaster::Reachable (AActor *actor, AActor *target)
bool FCajunMaster::Reachable (AActor *actor, AActor *target)
{
if (actor == target)
return false;
@ -128,7 +128,7 @@ bool DCajunMaster::Reachable (AActor *actor, AActor *target)
//if these conditions are true, the function returns true.
//GOOD TO KNOW is that the player's view angle
//in doom is 90 degrees infront.
bool DCajunMaster::Check_LOS (AActor *from, AActor *to, angle_t vangle)
bool FCajunMaster::Check_LOS (AActor *from, AActor *to, angle_t vangle)
{
if (!P_CheckSight (from, to, 2))
return false; // out of sight
@ -145,7 +145,7 @@ bool DCajunMaster::Check_LOS (AActor *from, AActor *to, angle_t vangle)
//-------------------------------------
//The bot will check if it's time to fire
//and do so if that is the case.
void DCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
void FCajunMaster::Dofire (AActor *actor, ticcmd_t *cmd)
{
bool no_fire; //used to prevent bot from pumping rockets into nearby walls.
int aiming_penalty=0; //For shooting at shading target, if screen is red, MAKEME: When screen red.
@ -288,7 +288,7 @@ shootmissile:
//This function is called every
//tick (for each bot) to set
//the mate (teammate coop mate).
AActor *DCajunMaster::Choose_Mate (AActor *bot)
AActor *FCajunMaster::Choose_Mate (AActor *bot)
{
int count;
int count2;
@ -369,7 +369,7 @@ AActor *DCajunMaster::Choose_Mate (AActor *bot)
//Make a introducing to mate.
if(target && target!=bot->player->last_mate)
{
if((P_Random()%(200*bglobal->botnum))<3)
if((P_Random()%(200*bglobal.botnum))<3)
{
bot->player->chat = c_teamup;
if(target->bot)
@ -385,7 +385,7 @@ AActor *DCajunMaster::Choose_Mate (AActor *bot)
}
//MAKEME: Make this a smart decision
AActor *DCajunMaster::Find_enemy (AActor *bot)
AActor *FCajunMaster::Find_enemy (AActor *bot)
{
int count;
fixed_t closest_dist, temp; //To target.
@ -448,7 +448,7 @@ AActor *DCajunMaster::Find_enemy (AActor *bot)
//Creates a temporary mobj (invisible) at the given location.
void DCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
{
if (hostnum == 1)
{
@ -459,7 +459,6 @@ void DCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
else
{
body1 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE);
GC::WriteBarrier(this, body1);
}
}
else if (hostnum == 2)
@ -471,7 +470,6 @@ void DCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
else
{
body2 = Spawn ("CajunBodyNode", x, y, z, NO_REPLACE);
GC::WriteBarrier(this, body2);
}
}
}
@ -486,7 +484,7 @@ void DCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum)
//Emulates missile travel. Returns distance travelled.
fixed_t DCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
{
AActor *th = Spawn ("CajunTrace", source->x, source->y, source->z + 4*8*FRACUNIT, NO_REPLACE);
@ -516,7 +514,7 @@ fixed_t DCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd)
return dist;
}
angle_t DCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
angle_t FCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
{
fixed_t dist;
angle_t ang;
@ -527,7 +525,7 @@ angle_t DCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
bot->y + FixedMul(bot->momy, 5*FRACUNIT),
bot->z + (bot->height / 2), 2);
actor = bglobal->body2;
actor = bglobal.body2;
dist = P_AproxDistance (actor->x-enemy->x, actor->y-enemy->y);
if (dist < SAFE_SELF_MISDIST)
@ -537,15 +535,15 @@ angle_t DCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
SetBodyAt (enemy->x + FixedMul (enemy->momx, (m+2*FRACUNIT)),
enemy->y + FixedMul(enemy->momy, (m+2*FRACUNIT)), ONFLOORZ, 1);
dist = P_AproxDistance(actor->x-bglobal->body1->x, actor->y-bglobal->body1->y);
dist = P_AproxDistance(actor->x-bglobal.body1->x, actor->y-bglobal.body1->y);
//try the predicted location
if (P_CheckSight (actor, bglobal->body1, 1)) //See the predicted location, so give a test missile
if (P_CheckSight (actor, bglobal.body1, 1)) //See the predicted location, so give a test missile
{
if (SafeCheckPosition (bot, actor->x, actor->y))
{
if (FakeFire (actor, bglobal->body1, cmd) >= SAFE_SELF_MISDIST)
if (FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST)
{
ang = R_PointToAngle2 (actor->x, actor->y, bglobal->body1->x, bglobal->body1->y);
ang = R_PointToAngle2 (actor->x, actor->y, bglobal.body1->x, bglobal.body1->y);
return ang;
}
}
@ -565,7 +563,7 @@ angle_t DCajunMaster::FireRox (AActor *bot, AActor *enemy, ticcmd_t *cmd)
// [RH] We absolutely do not want to pick things up here. The bot code is
// executed apart from all the other simulation code, so we don't want it
// creating side-effects during gameplay.
bool DCajunMaster::SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y)
bool FCajunMaster::SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y)
{
int savedFlags = actor->flags;
actor->flags &= ~MF_PICKUP;

View File

@ -61,7 +61,7 @@ Everything that is changed is marked (maybe commented) with "Added by MC"
static FRandom pr_botspawn ("BotSpawn");
//Externs
DCajunMaster *bglobal;
FCajunMaster bglobal;
cycle_t BotThinkCycles, BotSupportCycles, BotWTG;
@ -88,41 +88,14 @@ enum
static bool waitingforspawn[MAXPLAYERS];
DCajunMaster::DCajunMaster()
{
firstthing = NULL;
body1 = NULL;
body2 = NULL;
getspawned = NULL;
memset(botingame, 0, sizeof(botingame));
freeze = false;
changefreeze = false;
botnum = 0;
botinfo = NULL;
spawn_tries = 0;
wanted_botnum = NULL;
m_Thinking = false;
ctf = false;
loaded_bots = 0;
t_join = 0;
observer = false;
}
DCajunMaster::~DCajunMaster()
FCajunMaster::~FCajunMaster()
{
ForgetBots();
if (getspawned != NULL)
{
getspawned->Destroy();
getspawned = NULL;
}
// FIXME: Make this object proper
ObjectFlags |= OF_Cleanup | OF_YesReallyDelete;
}
//This function is called every tick (from g_game.c),
//send bots into thinking (+more).
void DCajunMaster::Main (int buf)
void FCajunMaster::Main (int buf)
{
int i;
@ -153,7 +126,7 @@ void DCajunMaster::Main (int buf)
{
if (t_join == ((wanted_botnum - botnum) * SPAWN_DELAY))
{
if (!SpawnBot (getspawned->GetArg (spawn_tries)))
if (!SpawnBot (getspawned[spawn_tries]))
wanted_botnum--;
spawn_tries++;
}
@ -184,7 +157,7 @@ void DCajunMaster::Main (int buf)
m_Thinking = false;
}
void DCajunMaster::Init ()
void FCajunMaster::Init ()
{
int i;
@ -230,25 +203,19 @@ void DCajunMaster::Init ()
}
//Called on each level exit (from g_game.c).
void DCajunMaster::End ()
void FCajunMaster::End ()
{
int i;
//Arrange wanted botnum and their names, so they can be spawned next level.
if (getspawned)
getspawned->FlushArgs ();
else
{
getspawned = new DArgs;
GC::WriteBarrier(this, getspawned);
}
getspawned.Clear();
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].isbot)
{
if (deathmatch)
{
getspawned->AppendArg (players[i].userinfo.netname);
getspawned.Push(players[i].userinfo.netname);
}
CleanBotstuff (&players[i]);
}
@ -272,7 +239,7 @@ void DCajunMaster::End ()
//The color parameter overides bots
//induvidual colors if not = NOCOLOR.
bool DCajunMaster::SpawnBot (const char *name, int color)
bool FCajunMaster::SpawnBot (const char *name, int color)
{
int playernumber;
@ -375,7 +342,7 @@ bool DCajunMaster::SpawnBot (const char *name, int color)
return true;
}
void DCajunMaster::DoAddBot (int bnum, char *info)
void FCajunMaster::DoAddBot (int bnum, char *info)
{
BYTE *infob = (BYTE *)info;
D_ReadUserInfoStrings (bnum, &infob, false);
@ -412,7 +379,7 @@ void DCajunMaster::DoAddBot (int bnum, char *info)
waitingforspawn[bnum] = false;
}
void DCajunMaster::RemoveAllBots (bool fromlist)
void FCajunMaster::RemoveAllBots (bool fromlist)
{
int i, j;
@ -452,7 +419,7 @@ void DCajunMaster::RemoveAllBots (bool fromlist)
//Clean the bot part of the player_t
//Used when bots are respawned or at level starts.
void DCajunMaster::CleanBotstuff (player_t *p)
void FCajunMaster::CleanBotstuff (player_t *p)
{
p->angle = ANG45;
p->dest = NULL;
@ -509,7 +476,7 @@ static void appendinfo (char *&front, const char *back)
front = newstr;
}
void DCajunMaster::ForgetBots ()
void FCajunMaster::ForgetBots ()
{
botinfo_t *thebot = botinfo;
@ -526,13 +493,13 @@ void DCajunMaster::ForgetBots ()
loaded_bots = 0;
}
bool DCajunMaster::LoadBots ()
bool FCajunMaster::LoadBots ()
{
FScanner sc;
FString tmp;
bool gotteam = false;
bglobal->ForgetBots ();
bglobal.ForgetBots ();
#ifndef unix
tmp = progdir;
tmp += "zcajun/" BOTFILENAME;
@ -662,12 +629,12 @@ bool DCajunMaster::LoadBots ()
appendinfo (newinfo->info, "team");
appendinfo (newinfo->info, "255");
}
newinfo->next = bglobal->botinfo;
newinfo->next = bglobal.botinfo;
newinfo->lastteam = TEAM_None;
bglobal->botinfo = newinfo;
bglobal->loaded_bots++;
bglobal.botinfo = newinfo;
bglobal.loaded_bots++;
}
Printf ("%d bots read from %s\n", bglobal->loaded_bots, BOTFILENAME);
Printf ("%d bots read from %s\n", bglobal.loaded_bots, BOTFILENAME);
return true;
}

View File

@ -46,7 +46,7 @@ extern TArray<line_t *> spechit;
//Called while the bot moves after its player->dest mobj
//which can be a weapon/enemy/item whatever.
void DCajunMaster::Roam (AActor *actor, ticcmd_t *cmd)
void FCajunMaster::Roam (AActor *actor, ticcmd_t *cmd)
{
int delta;
@ -72,7 +72,7 @@ void DCajunMaster::Roam (AActor *actor, ticcmd_t *cmd)
}
}
bool DCajunMaster::Move (AActor *actor, ticcmd_t *cmd)
bool FCajunMaster::Move (AActor *actor, ticcmd_t *cmd)
{
fixed_t tryx, tryy;
bool try_ok;
@ -130,7 +130,7 @@ bool DCajunMaster::Move (AActor *actor, ticcmd_t *cmd)
return true;
}
bool DCajunMaster::TryWalk (AActor *actor, ticcmd_t *cmd)
bool FCajunMaster::TryWalk (AActor *actor, ticcmd_t *cmd)
{
if (!Move (actor, cmd))
return false;
@ -139,7 +139,7 @@ bool DCajunMaster::TryWalk (AActor *actor, ticcmd_t *cmd)
return true;
}
void DCajunMaster::NewChaseDir (AActor *actor, ticcmd_t *cmd)
void FCajunMaster::NewChaseDir (AActor *actor, ticcmd_t *cmd)
{
fixed_t deltax;
fixed_t deltay;
@ -275,7 +275,7 @@ void DCajunMaster::NewChaseDir (AActor *actor, ticcmd_t *cmd)
// This is also a traverse function for
// bots pre-rocket fire (preventing suicide)
//
bool DCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cmd)
bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cmd)
{
if (!SafeCheckPosition (thing, x, y))
return false; // solid wall or thing
@ -322,7 +322,7 @@ bool DCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm
#define MAXTURN (15*ANGLE_1) //Max degrees turned in one tic. Lower is smother but may cause the bot not getting where it should = crash
#define TURNSENS 3 //Higher is smoother but slower turn.
void DCajunMaster::TurnToAng (AActor *actor)
void FCajunMaster::TurnToAng (AActor *actor)
{
int maxturn = MAXTURN;
@ -356,7 +356,7 @@ void DCajunMaster::TurnToAng (AActor *actor)
actor->angle += distance;
}
void DCajunMaster::Pitch (AActor *actor, AActor *target)
void FCajunMaster::Pitch (AActor *actor, AActor *target)
{
double aim;
double diff;
@ -367,7 +367,7 @@ void DCajunMaster::Pitch (AActor *actor, AActor *target)
}
//Checks if a sector is dangerous.
bool DCajunMaster::IsDangerous (sector_t *sec)
bool FCajunMaster::IsDangerous (sector_t *sec)
{
int special;

View File

@ -23,7 +23,7 @@ static FRandom pr_botmove ("BotMove");
//This function is called each tic for each bot,
//so this is what the bot does.
void DCajunMaster::Think (AActor *actor, ticcmd_t *cmd)
void FCajunMaster::Think (AActor *actor, ticcmd_t *cmd)
{
memset (cmd, 0, sizeof(*cmd));
@ -71,7 +71,7 @@ void DCajunMaster::Think (AActor *actor, ticcmd_t *cmd)
//how the bot moves.
//MAIN movement function.
void DCajunMaster::ThinkForMove (AActor *actor, ticcmd_t *cmd)
void FCajunMaster::ThinkForMove (AActor *actor, ticcmd_t *cmd)
{
player_t *b;
fixed_t dist;
@ -312,7 +312,7 @@ void DCajunMaster::ThinkForMove (AActor *actor, ticcmd_t *cmd)
//BOT_WhatToGet
//
//Determines if the bot will roam after an item or not.
void DCajunMaster::WhatToGet (AActor *actor, AActor *item)
void FCajunMaster::WhatToGet (AActor *actor, AActor *item)
{
player_t *b = actor->player;
@ -329,7 +329,7 @@ void DCajunMaster::WhatToGet (AActor *actor, AActor *item)
}
int weapgiveammo = (alwaysapplydmflags || deathmatch) && !(dmflags & DF_WEAPONS_STAY);
//if(pos && !bglobal->thingvis[pos->id][item->id]) continue;
//if(pos && !bglobal.thingvis[pos->id][item->id]) continue;
// if (item->IsKindOf (RUNTIME_CLASS(AArtifact)))
// return; // don't know how to use artifacts
if (item->IsKindOf (RUNTIME_CLASS(AWeapon)))
@ -376,7 +376,7 @@ void DCajunMaster::WhatToGet (AActor *actor, AActor *item)
}
}
void DCajunMaster::Set_enemy (AActor *actor)
void FCajunMaster::Set_enemy (AActor *actor)
{
AActor *oldenemy;
AActor **enemy = &actor->player->enemy;

View File

@ -127,6 +127,7 @@ FBaseCVar::~FBaseCVar ()
else
CVars = m_Next;
}
C_RemoveTabCommand(Name);
delete[] Name;
}
}

View File

@ -718,7 +718,7 @@ void D_Display ()
void D_ErrorCleanup ()
{
screen->Unlock ();
bglobal->RemoveAllBots (true);
bglobal.RemoveAllBots (true);
D_QuitNetGame ();
if (demorecording || demoplayback)
G_CheckDemoStatus ();
@ -772,7 +772,7 @@ void D_DoomLoop ()
players[i].savedpitch = players[i].mo->pitch;
}
}
bglobal->Main (maketic%BACKUPTICS);
bglobal.Main (maketic%BACKUPTICS);
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].isbot && players[i].mo)
@ -1526,6 +1526,7 @@ static int CheckIWAD (const char *doomwaddir, WadStuff *wads)
iwad.Format ("%s%s%s", doomwaddir, slash, IWADNames[i]);
FixPathSeperator (iwad.LockBuffer());
iwad.UnlockBuffer();
if (FileExists (iwad))
{
wads[i].Type = ScanIWAD (iwad);
@ -1656,7 +1657,7 @@ static int CheckIWADinEnvDir (const char *str, WadStuff *wads)
static EIWADType IdentifyVersion (const char *zdoom_wad)
{
WadStuff wads[sizeof(IWADNames)/sizeof(char *)];
WadStuff wads[countof(IWADNames)];
size_t foundwads[NUM_IWAD_TYPES] = { 0 };
const char *iwadparm = Args->CheckValue ("-iwad");
size_t numwads;
@ -1746,7 +1747,7 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
{
wads[numwads] = wads[i];
}
foundwads[wads[numwads].Type] = numwads+1;
foundwads[wads[numwads].Type] = numwads + 1;
numwads++;
}
}
@ -1754,11 +1755,19 @@ static EIWADType IdentifyVersion (const char *zdoom_wad)
if (foundwads[IWAD_HexenDK] && !foundwads[IWAD_Hexen])
{ // Cannot play Hexen DK without Hexen
size_t kill = foundwads[IWAD_HexenDK];
if (kill != numwads)
for (i = kill; i < numwads; ++i)
{
memmove (&wads[kill-1], &wads[kill], numwads - kill);
wads[i - 1] = wads[i];
}
numwads--;
foundwads[IWAD_HexenDK] = 0;
for (i = 0; i < NUM_IWAD_TYPES; ++i)
{
if (foundwads[i] > kill)
{
foundwads[i]--;
}
}
}
if (numwads == 0)
@ -2433,18 +2442,13 @@ void D_DoomMain (void)
}
//Added by MC:
bglobal->getspawned = Args->GatherFiles ("-bots", "", false);
if (bglobal->getspawned->NumArgs() == 0)
DArgs *bots = Args->GatherFiles("-bots", "", false);
for (p = 0; p < bots->NumArgs(); ++p)
{
bglobal->getspawned->Destroy();
bglobal->getspawned = NULL;
}
else
{
GC::WriteBarrier(bglobal, bglobal->getspawned);
bglobal->spawn_tries = 0;
bglobal->wanted_botnum = bglobal->getspawned->NumArgs();
bglobal.getspawned.Push(bots->GetArg(p));
}
bglobal.spawn_tries = 0;
bglobal.wanted_botnum = bglobal.getspawned.Size();
Printf ("M_Init: Init miscellaneous info.\n");
M_Init ();

View File

@ -641,7 +641,7 @@ void PlayerIsGone (int netnode, int netconsole)
FBehavior::StaticStartTypedScripts (SCRIPT_Disconnect, NULL, true, netconsole);
if (netconsole == Net_Arbitrator)
{
bglobal->RemoveAllBots (true);
bglobal.RemoveAllBots (true);
Printf ("Removed all bots\n");
// Pick a new network arbitrator
@ -966,7 +966,7 @@ void NetUpdate (void)
if (maketic % ticdup == 0)
{
//Added by MC: For some of that bot stuff. The main bot function.
bglobal->Main ((maketic / ticdup) % BACKUPTICS);
bglobal.Main ((maketic / ticdup) % BACKUPTICS);
}
maketic++;
@ -2048,12 +2048,12 @@ void Net_DoCommand (int type, BYTE **stream, int player)
case DEM_ADDBOT:
{
BYTE num = ReadByte (stream);
bglobal->DoAddBot (num, s = ReadString (stream));
bglobal.DoAddBot (num, s = ReadString (stream));
}
break;
case DEM_KILLBOTS:
bglobal->RemoveAllBots (true);
bglobal.RemoveAllBots (true);
Printf ("Removed all bots\n");
break;

View File

@ -1135,7 +1135,7 @@ void DDecalFader::Tick ()
}
else
{
if (level.maptime < TimeToStartDecay || bglobal->freeze)
if (level.maptime < TimeToStartDecay || bglobal.freeze)
{
return;
}
@ -1218,7 +1218,7 @@ void DDecalStretcher::Tick ()
Destroy ();
return;
}
if (level.maptime < TimeToStart || bglobal->freeze)
if (level.maptime < TimeToStart || bglobal.freeze)
{
return;
}
@ -1287,7 +1287,7 @@ void DDecalSlider::Tick ()
Destroy ();
return;
}
if (level.maptime < TimeToStart || bglobal->freeze)
if (level.maptime < TimeToStart || bglobal.freeze)
{
return;
}
@ -1353,7 +1353,7 @@ void DDecalColorer::Tick ()
}
else
{
if (level.maptime < TimeToStartDecay || bglobal->freeze)
if (level.maptime < TimeToStartDecay || bglobal.freeze)
{
return;
}

View File

@ -492,7 +492,7 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld)
for (i = 0; i < numsectors; ++i)
{
#define SECTOR_CHECK(f,t) \
if (sectors[i].f == static_cast<t *>(old)) { sectors[i].f = static_cast<t *>(notOld); changed++; }
if (sectors[i].f.p == static_cast<t *>(old)) { sectors[i].f = static_cast<t *>(notOld); changed++; }
SECTOR_CHECK( SoundTarget, AActor );
SECTOR_CHECK( CeilingSkyBox, ASkyViewpoint );
SECTOR_CHECK( FloorSkyBox, ASkyViewpoint );
@ -503,6 +503,12 @@ size_t DObject::StaticPointerSubstitution (DObject *old, DObject *notOld)
#undef SECTOR_CHECK
}
}
// Go through bot stuff.
if (bglobal.firstthing.p == (AActor *)old) bglobal.firstthing = (AActor *)notOld, ++changed;
if (bglobal.body1.p == (AActor *)old) bglobal.body1 = (AActor *)notOld, ++changed;
if (bglobal.body2.p == (AActor *)old) bglobal.body2 = (AActor *)notOld, ++changed;
return changed;
}

View File

@ -400,6 +400,7 @@ public:
}
template<class U> friend inline FArchive &operator<<(FArchive &arc, TObjPtr<U> &o);
friend class DObject;
};
template<class T> inline FArchive &operator<<(FArchive &arc, TObjPtr<T> &o)

View File

@ -289,15 +289,18 @@ static void MarkRoot()
DThinker::MarkRoots();
FCanvasTextureInfo::Mark();
Mark(DACSThinker::ActiveThinker);
// Mark dead bodies.
for (i = 0; i < BODYQUESIZE; ++i)
{
Mark(bodyque[i]);
}
// Mark players.
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i])
players[i].PropagateMark();
}
// Mark sectors.
if (SectorMarker == NULL && sectors != NULL)
{
SectorMarker = new DSectorMarker;
@ -311,10 +314,11 @@ static void MarkRoot()
SectorMarker->SecNum = 0;
}
Mark(SectorMarker);
{ // Silly bots
Mark(bglobal);
}
// Add soft roots
// Mark bot stuff.
Mark(bglobal.firstthing);
Mark(bglobal.body1);
Mark(bglobal.body2);
// Mark soft roots.
if (SoftRoots != NULL)
{
DObject **probe = &SoftRoots->ObjNext;
@ -328,6 +332,7 @@ static void MarkRoot()
}
}
}
// Time to propagate the marks.
State = GCS_Propagate;
StepCount = 0;
}

View File

@ -1218,8 +1218,8 @@ void G_PlayerReborn (int player)
}
//Added by MC: Init bot structure.
if (bglobal->botingame[player])
bglobal->CleanBotstuff (p);
if (bglobal.botingame[player])
bglobal.CleanBotstuff (p);
else
p->isbot = false;
@ -1764,7 +1764,7 @@ void G_DoLoadGame ()
// Read intermission data for hubs
G_ReadHubInfo(png);
bglobal->RemoveAllBots (true);
bglobal.RemoveAllBots (true);
text = M_GetPNGText (png, "Important CVARs");
if (text != NULL)

View File

@ -1693,7 +1693,7 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
//Added by MC: Initialize bots.
if (!deathmatch)
{
bglobal->Init ();
bglobal.Init ();
}
if (mapname != level.mapname)
@ -1761,7 +1761,7 @@ void G_ChangeLevel(const char * levelname, int position, bool keepFacing, int ne
gameaction = ga_completed;
resetinventory = resetinv;
bglobal->End(); //Added by MC:
bglobal.End(); //Added by MC:
// [RH] Give scripts a chance to do something
unloading = true;
@ -2109,7 +2109,7 @@ void G_DoLoadLevel (int position, bool autosave)
//Added by MC: Initialize bots.
if (deathmatch)
{
bglobal->Init ();
bglobal.Init ();
}
if (timingdemo)

View File

@ -1072,9 +1072,9 @@ int SBarInfo::getSignedInteger(FScanner &sc)
}
}
int SBarInfo::newImage(const char* patchname)
int SBarInfo::newImage(const char *patchname)
{
if(stricmp(patchname, "nullimage") == 0)
if(patchname[0] == '\0' || stricmp(patchname, "nullimage") == 0)
{
return -1;
}

View File

@ -403,8 +403,8 @@ void cht_DoCheat (player_t *player, int cheat)
break;
case CHT_FREEZE:
bglobal->changefreeze ^= 1;
if (bglobal->freeze ^ bglobal->changefreeze)
bglobal.changefreeze ^= 1;
if (bglobal.freeze ^ bglobal.changefreeze)
{
msg = "Freeze mode on";
}

View File

@ -561,10 +561,10 @@ void AActor::Die (AActor *source, AActor *inflictor)
player->respawn_time = level.time + TICRATE;
//Added by MC: Respawn bots
if (bglobal->botnum && consoleplayer == Net_Arbitrator && !demoplayback)
if (bglobal.botnum && consoleplayer == Net_Arbitrator && !demoplayback)
{
if (player->isbot)
player->t_respawn = (pr_botrespawn()%15)+((bglobal->botnum-1)*2)+TICRATE+1;
player->t_respawn = (pr_botrespawn()%15)+((bglobal.botnum-1)*2)+TICRATE+1;
//Added by MC: Discard enemies.
for (int i = 0; i < MAXPLAYERS; i++)

View File

@ -1739,7 +1739,7 @@ bool P_TryMove (AActor *thing, fixed_t x, fixed_t y,
if (thing->player && thing->player->isbot && thing->flags & MF_SHOOTABLE)
{
if (tmsector != thing->Sector
&& bglobal->IsDangerous (tmsector))
&& bglobal.IsDangerous (tmsector))
{
thing->player->prev = thing->player->dest;
thing->player->dest = NULL;

View File

@ -2558,7 +2558,7 @@ void AActor::Tick ()
}
//Added by MC: Freeze mode.
if (bglobal->freeze && !(player && !player->isbot))
if (bglobal.freeze && !(player && !player->isbot))
{
return;
}
@ -2637,11 +2637,11 @@ void AActor::Tick ()
}
}
if (bglobal->botnum && consoleplayer == Net_Arbitrator && !demoplayback &&
if (bglobal.botnum && consoleplayer == Net_Arbitrator && !demoplayback &&
(flags & (MF_SPECIAL|MF_MISSILE)) || (flags3 & MF3_ISMONSTER))
{
clock (BotSupportCycles);
bglobal->m_Thinking = true;
bglobal.m_Thinking = true;
for (i = 0; i < MAXPLAYERS; i++)
{
if (!playeringame[i] || !players[i].isbot)
@ -2661,7 +2661,7 @@ void AActor::Tick ()
else if (flags & MF_SPECIAL)
{ //Item pickup time
//clock (BotWTG);
bglobal->WhatToGet (players[i].mo, this);
bglobal.WhatToGet (players[i].mo, this);
//unclock (BotWTG);
BotWTG++;
}
@ -2669,12 +2669,12 @@ void AActor::Tick ()
{
if (!players[i].missile && (flags3 & MF3_WARNBOT))
{ //warn for incoming missiles.
if (target != players[i].mo && bglobal->Check_LOS (players[i].mo, this, ANGLE_90))
if (target != players[i].mo && bglobal.Check_LOS (players[i].mo, this, ANGLE_90))
players[i].missile = this;
}
}
}
bglobal->m_Thinking = false;
bglobal.m_Thinking = false;
unclock (BotSupportCycles);
}
@ -3158,7 +3158,7 @@ AActor *AActor::StaticSpawn (const PClass *type, fixed_t ix, fixed_t iy, fixed_t
actor->z = actor->PrevZ = iz;
actor->picnum = 0xffff;
FRandom &rng = bglobal->m_Thinking ? pr_botspawnmobj : pr_spawnmobj;
FRandom &rng = bglobal.m_Thinking ? pr_botspawnmobj : pr_spawnmobj;
if (actor->isFast() && actor->flags3 & MF3_ISMONSTER)
actor->reactiontime = 0;

View File

@ -230,7 +230,7 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
if (dst->isbot)
{
botinfo_t *thebot = bglobal->botinfo;
botinfo_t *thebot = bglobal.botinfo;
while (thebot && stricmp (name, thebot->name))
{
thebot = thebot->next;
@ -239,8 +239,8 @@ static void CopyPlayer (player_t *dst, player_t *src, const char *name)
{
thebot->inuse = true;
}
bglobal->botnum++;
bglobal->botingame[dst - players] = true;
bglobal.botnum++;
bglobal.botingame[dst - players] = true;
}
else
{

View File

@ -496,7 +496,7 @@ sightcounts[0]++;
// Cannot see an invisible object
if ((flags & 1) == 0 && ((t2->renderflags & RF_INVISIBLE) || !t2->RenderStyle.IsVisible(t2->alpha)))
{ // small chance of an attack being made anyway
if ((bglobal->m_Thinking ? pr_botchecksight() : pr_checksight()) > 50)
if ((bglobal.m_Thinking ? pr_botchecksight() : pr_checksight()) > 50)
{
res = false;
goto done;

View File

@ -78,10 +78,10 @@ void P_Ticker (void)
// [RH] Frozen mode is only changed every 4 tics, to make it work with A_Tracer().
if ((level.time & 3) == 0)
{
if (bglobal->changefreeze)
if (bglobal.changefreeze)
{
bglobal->freeze ^= 1;
bglobal->changefreeze = 0;
bglobal.freeze ^= 1;
bglobal.changefreeze = 0;
}
}
@ -102,7 +102,7 @@ void P_Ticker (void)
// Since things will be moving, it's okay to interpolate them in the renderer.
r_NoInterpolate = false;
if (!bglobal->freeze && !(level.flags & LEVEL_FROZEN))
if (!bglobal.freeze && !(level.flags & LEVEL_FROZEN))
{
P_ThinkParticles (); // [RH] make the particles think
}
@ -110,14 +110,14 @@ void P_Ticker (void)
for (i = 0; i<MAXPLAYERS; i++)
if (playeringame[i] &&
/*Added by MC: Freeze mode.*/!(bglobal->freeze && players[i].isbot))
/*Added by MC: Freeze mode.*/!(bglobal.freeze && players[i].isbot))
P_PlayerThink (&players[i]);
level.Tick (); // [RH] let the level tick
DThinker::RunThinkers ();
//if added by MC: Freeze mode.
if (!bglobal->freeze && !(level.flags & LEVEL_FROZEN))
if (!bglobal.freeze && !(level.flags & LEVEL_FROZEN))
{
P_UpdateSpecials ();
P_RunEffects (); // [RH] Run particle effects

View File

@ -132,7 +132,6 @@ void STACK_ARGS call_terms ()
static void FinalGC()
{
Args = NULL;
bglobal = NULL;
GC::FullGC();
}

View File

@ -244,7 +244,7 @@ TimiditySong::TimiditySong (FILE *file, char * musiccache, int len)
void TimiditySong::PrepTimidity ()
{
int pipeSize;
#ifdef _WIN32
static SECURITY_ATTRIBUTES inheritable = { sizeof(inheritable), NULL, TRUE };
@ -268,11 +268,11 @@ void TimiditySong::PrepTimidity ()
pipeSize = (timidity_pipe * timidity_frequency / 1000)
<< (timidity_stereo + !timidity_8bit);
if (GSnd == NULL)
{ // Can't pipe if using no sound.
pipeSize = 0;
}
if (GSnd == NULL)
{ // Can't pipe if using no sound.
pipeSize = 0;
}
if (pipeSize != 0)
{
@ -529,7 +529,7 @@ bool TimiditySong::LaunchTimidity ()
// freopen ("/dev/null", "w", stderr);
close (WavePipe[1]);
execvp (words.we_wordv[0], words.we_wordv);
execvp (words.we_wordv[0], words.we_wordv);
fprintf(stderr,"execvp failed\n");
exit (0); // if execvp succeeds, we never get here
}
@ -542,11 +542,11 @@ bool TimiditySong::LaunchTimidity ()
// printf ("child is %d\n", forkres);
ChildProcess = forkres;
close (WavePipe[1]);
WavePipe[1] = -1;
/* usleep(1000000);
if (waitpid(ChildProcess, NULL, WNOHANG) == ChildProcess)
{
fprintf(stderr,"Launching timidity failed\n");
WavePipe[1] = -1;
/* usleep(1000000);
if (waitpid(ChildProcess, NULL, WNOHANG) == ChildProcess)
{
fprintf(stderr,"Launching timidity failed\n");
}*/
}
@ -586,10 +586,10 @@ bool TimiditySong::FillStream (SoundStream *stream, void *buff, int len, void *u
}
}
#else
ssize_t got;
fd_set rfds;
struct timeval tv;
ssize_t got;
fd_set rfds;
struct timeval tv;
if (ChildQuit == song->ChildProcess)
{
ChildQuit = 0;
@ -597,18 +597,18 @@ bool TimiditySong::FillStream (SoundStream *stream, void *buff, int len, void *u
song->ChildProcess = -1;
return false;
}
FD_ZERO(&rfds);
FD_SET(song->WavePipe[0], &rfds);
tv.tv_sec = 0;
tv.tv_usec = 50;
// fprintf(stderr,"select\n");
if (select(1, &rfds, NULL, NULL, &tv) <= 0 && 0)
{ // Nothing available, so play silence.
// fprintf(stderr,"nothing\n");
// memset(buff, 0, len);
return true;
}
FD_ZERO(&rfds);
FD_SET(song->WavePipe[0], &rfds);
tv.tv_sec = 0;
tv.tv_usec = 50;
// fprintf(stderr,"select\n");
if (select(1, &rfds, NULL, NULL, &tv) <= 0 && 0)
{ // Nothing available, so play silence.
// fprintf(stderr,"nothing\n");
// memset(buff, 0, len);
return true;
}
// fprintf(stderr,"something\n");
got = read (song->WavePipe[0], (BYTE *)buff, len);

View File

@ -50,14 +50,14 @@ StreamSong::~StreamSong ()
}
StreamSong::StreamSong (const char *filename_or_data, int offset, int len)
{
if (GSnd != NULL)
{
if (GSnd != NULL)
{
m_Stream = GSnd->OpenStream (filename_or_data, SoundStream::Loop, offset, len);
}
else
{
m_Stream = NULL;
m_Stream = GSnd->OpenStream (filename_or_data, SoundStream::Loop, offset, len);
}
else
{
m_Stream = NULL;
}
}

View File

@ -80,8 +80,23 @@
#if SVN_REVISION_NUMBER < MINSAVEVER
// Never write a savegame with a version lower than what we need
#define SAVEVER MINSAVEVER
#define MAKESAVESIG(x) "ZDOOMSAVE" #x
#define SAVESIG MAKESAVESIG(SAVEVER)
#define SAVESIG MakeSaveSig()
static inline const char *MakeSaveSig()
{
static char foo[] = { 'Z','D','O','O','M','S','A','V','E',
#if SAVEVER > 9999
'0' + (SAVEVER / 10000),
#endif
#if SAVEVER > 999
'0' + ((SAVEVER / 1000) % 10),
#endif
'0' + ((SAVEVER / 100) % 10),
'0' + ((SAVEVER / 10) % 10),
'0' + (SAVEVER % 10),
'\0'
};
return foo;
}
#else
#define SAVEVER SVN_REVISION_NUMBER
#define SAVESIG "ZDOOMSAVE"SVN_REVISION_STRING

View File

@ -1039,7 +1039,7 @@ void WI_End ()
//Added by mc
if (deathmatch)
{
bglobal->RemoveAllBots (consoleplayer != Net_Arbitrator);
bglobal.RemoveAllBots (consoleplayer != Net_Arbitrator);
}
}

View File

@ -397,6 +397,7 @@ void D3DFB::FillPresentParameters (D3DPRESENT_PARAMETERS *pp, bool fullscreen, b
pp->BackBufferWidth = Width << PixelDoubling;
pp->BackBufferHeight = TrueHeight << PixelDoubling;
pp->BackBufferFormat = fullscreen ? D3DFMT_A8R8G8B8 : D3DFMT_UNKNOWN;
pp->BackBufferCount = 1;
pp->hDeviceWindow = Window;
pp->PresentationInterval = vsync ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE;
if (fullscreen)

View File

@ -249,7 +249,6 @@ static void UnWTS (void)
static void FinalGC()
{
Args = NULL;
bglobal = NULL;
GC::FullGC();
}