- Made DBot inherit from DObject.

This commit is contained in:
ChillyDoom 2014-10-15 17:54:12 +01:00
parent db323643f8
commit c400dcf736
6 changed files with 41 additions and 21 deletions

View file

@ -24,6 +24,11 @@ IMPLEMENT_POINTY_CLASS(DBot)
END_POINTERS
DBot::DBot ()
{
Clear ();
}
void DBot::Clear ()
{
savedyaw = 0;
savedpitch = 0;
@ -123,6 +128,11 @@ void FCajunMaster::ClearPlayer (int i, bool keepTeam)
bot->inuse = false;
bot->lastteam = keepTeam ? players[i].userinfo.GetTeam() : TEAM_NONE;
}
if (players[i].Bot != NULL)
{
players[i].Bot->Destroy ();
players[i].Bot = NULL;
}
players[i].~player_t();
::new(&players[i]) player_t;
players[i].userinfo.Reset();

View file

@ -90,6 +90,7 @@ public:
void ForgetBots ();
void DoAddBot (BYTE **stream);
void RemoveAllBots (bool fromlist);
void DestroyAllBots ();
//(B_Func.c)
bool Check_LOS (AActor *mobj1, AActor *mobj2, angle_t vangle);
@ -143,13 +144,14 @@ protected:
bool observer; //Consoleplayer is observer.
};
class DBot : public DThinker
class DBot : public DObject
{
DECLARE_CLASS(DBot,DThinker)
DECLARE_CLASS(DBot,DObject)
HAS_OBJECT_POINTERS
public:
DBot ();
void Clear ();
void Serialize (FArchive &arc);
angle_t savedyaw;

View file

@ -352,6 +352,9 @@ void FCajunMaster::DoAddBot (BYTE **stream)
skill.isp = ReadByte (stream);
D_ReadUserInfoStrings (bnum, &infob, false);
delete[] info;
if (!deathmatch && playerstarts[bnum].type == 0)
{
Printf ("%s tried to join, but there was no player %d start\n",
@ -423,6 +426,18 @@ void FCajunMaster::RemoveAllBots (bool fromlist)
botnum = 0;
}
void FCajunMaster::DestroyAllBots ()
{
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (players[i].Bot != NULL)
{
players[i].Bot->Destroy ();
players[i].Bot = NULL;
}
}
}
//------------------
//Reads data for bot from

View file

@ -1341,7 +1341,7 @@ void G_PlayerReborn (int player)
APlayerPawn *actor;
const PClass *cls;
FString log;
DBot *OldBot; //Added by MC:
DBot *Bot; //Added by MC:
p = &players[player];
@ -1356,7 +1356,7 @@ void G_PlayerReborn (int player)
cls = p->cls;
log = p->LogText;
chasecam = p->cheats & CF_CHASECAM;
OldBot = p->Bot; //Added by MC:
Bot = p->Bot; //Added by MC:
// Reset player structure to its defaults
p->~player_t();
@ -1373,13 +1373,7 @@ void G_PlayerReborn (int player)
p->cls = cls;
p->LogText = log;
p->cheats |= chasecam;
//Added by MC: Init bot structure.
if (OldBot != NULL)
{
p->Bot = new DBot;
p->Bot->skill = OldBot->skill;
}
p->Bot = Bot; //Added by MC:
p->oldbuttons = ~0, p->attackdown = true; p->usedown = true; // don't do anything immediately
p->original_oldbuttons = ~0;
@ -1390,6 +1384,14 @@ void G_PlayerReborn (int player)
actor->GiveDefaultInventory ();
p->ReadyWeapon = p->PendingWeapon;
}
//Added by MC: Init bot structure.
if (p->Bot != NULL)
{
botskill_t skill = p->Bot->skill;
p->Bot->Clear ();
p->Bot->skill = skill;
}
}
//

View file

@ -1110,11 +1110,6 @@ void G_StartTravel ()
P_DelSector_List ();
}
}
if (players[i].Bot != NULL)
{
players[i].Bot->ChangeStatNum (STAT_TRAVELLING);
}
}
}
}
@ -1189,11 +1184,6 @@ void G_FinishTravel ()
pawn->SetState(pawn->SpawnState);
pawn->player->SendPitchLimits();
if (pawn->player->Bot != NULL)
{
pawn->player->Bot->ChangeStatNum (STAT_DEFAULT);
}
for (inv = pawn->Inventory; inv != NULL; inv = inv->Inventory)
{
inv->ChangeStatNum (STAT_INVENTORY);

View file

@ -4175,6 +4175,7 @@ static void P_Shutdown ()
P_FreeLevelData ();
P_FreeExtraLevelData ();
ST_Clear();
bglobal.DestroyAllBots ();
}
#if 0