mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2025-01-31 04:20:34 +00:00
- Added Remove <classname> console command.
This commit is contained in:
parent
794d2240eb
commit
cac600733f
3 changed files with 68 additions and 0 deletions
|
@ -2082,6 +2082,33 @@ static int KillAll(const PClass *cls)
|
|||
}
|
||||
return killcount;
|
||||
|
||||
}
|
||||
|
||||
static int RemoveClass(const PClass *cls)
|
||||
{
|
||||
AActor *actor;
|
||||
int removecount = 0;
|
||||
bool player = false;
|
||||
TThinkerIterator<AActor> iterator(cls);
|
||||
while ((actor = iterator.Next()))
|
||||
{
|
||||
if (actor->IsA(cls))
|
||||
{
|
||||
// [MC]Do not remove LIVE players.
|
||||
if (actor->IsKindOf(RUNTIME_CLASS(APlayerPawn)) && actor->player != NULL)
|
||||
{
|
||||
player = true;
|
||||
continue;
|
||||
}
|
||||
removecount++;
|
||||
actor->ClearCounters();
|
||||
actor->Destroy();
|
||||
}
|
||||
}
|
||||
if (player)
|
||||
Printf("Cannot remove live players!\n");
|
||||
return removecount;
|
||||
|
||||
}
|
||||
// [RH] Execute a special "ticcmd". The type byte should
|
||||
// have already been read, and the stream is positioned
|
||||
|
@ -2555,6 +2582,27 @@ void Net_DoCommand (int type, BYTE **stream, int player)
|
|||
|
||||
}
|
||||
break;
|
||||
case DEM_REMOVE:
|
||||
{
|
||||
char *classname = ReadString(stream);
|
||||
int removecount = 0;
|
||||
const PClass *cls = PClass::FindClass(classname);
|
||||
if (cls != NULL && cls->ActorInfo != NULL)
|
||||
{
|
||||
removecount = RemoveClass(cls);
|
||||
const PClass *cls_rep = cls->GetReplacement();
|
||||
if (cls != cls_rep)
|
||||
{
|
||||
removecount += RemoveClass(cls_rep);
|
||||
}
|
||||
Printf("Removed %d actors of type %s.\n", removecount, classname);
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("%s is not an actor class.\n", classname);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case DEM_CONVREPLY:
|
||||
case DEM_CONVCLOSE:
|
||||
|
|
|
@ -164,6 +164,7 @@ enum EDemoCommand
|
|||
DEM_RUNNAMEDSCRIPT, // 65 String: Script name, Byte: Arg count + Always flag; each arg is a 4-byte int
|
||||
DEM_REVERTCAMERA, // 66
|
||||
DEM_SETSLOTPNUM, // 67 Byte: player number, the rest is the same as DEM_SETSLOT
|
||||
DEM_REMOVE, // 68
|
||||
};
|
||||
|
||||
// The following are implemented by cht_DoCheat in m_cheat.cpp
|
||||
|
|
|
@ -1841,3 +1841,22 @@ CCMD (kill)
|
|||
}
|
||||
C_HideConsole ();
|
||||
}
|
||||
|
||||
CCMD(remove)
|
||||
{
|
||||
if (argv.argc() == 2)
|
||||
{
|
||||
if (CheckCheatmode())
|
||||
return;
|
||||
|
||||
Net_WriteByte(DEM_REMOVE);
|
||||
Net_WriteString(argv[1]);
|
||||
C_HideConsole();
|
||||
}
|
||||
else
|
||||
{
|
||||
Printf("Usage: remove <actor class name>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in a new issue