Browse Source

Fix enttools bugs

gravgun
mittorn 7 years ago
parent
commit
edb78b4e0e
  1. 1
      android/jni/server
  2. 2
      dlls/cbase.cpp
  3. 195
      dlls/enttools.cpp

1
android/jni/server

@ -1 +0,0 @@
../../dlls

2
dlls/cbase.cpp

@ -602,6 +602,8 @@ TYPEDESCRIPTION CBaseEntity::m_SaveData[] =
DEFINE_FIELD( CBaseEntity, m_pfnTouch, FIELD_FUNCTION ), DEFINE_FIELD( CBaseEntity, m_pfnTouch, FIELD_FUNCTION ),
DEFINE_FIELD( CBaseEntity, m_pfnUse, FIELD_FUNCTION ), DEFINE_FIELD( CBaseEntity, m_pfnUse, FIELD_FUNCTION ),
DEFINE_FIELD( CBaseEntity, m_pfnBlocked, FIELD_FUNCTION ), DEFINE_FIELD( CBaseEntity, m_pfnBlocked, FIELD_FUNCTION ),
DEFINE_FIELD( CBaseEntity, enttools_data.enttools, FIELD_CHARACTER ),
DEFINE_ARRAY( CBaseEntity, enttools_data.ownerid, FIELD_CHARACTER, 33 ),
}; };
int CBaseEntity::Save( CSave &save ) int CBaseEntity::Save( CSave &save )

195
dlls/enttools.cpp

@ -76,15 +76,16 @@ typedef struct entblacklist_s
char pattern[32]; char pattern[32];
int limit; int limit;
int behaviour; int behaviour;
bool clear;
} entblacklist_t; } entblacklist_t;
entblacklist_t *entblacklist; entblacklist_t *entblacklist;
void Ent_AddToBlacklist_f( void ) void Ent_AddToBlacklist_f( void )
{ {
if( CMD_ARGC() != 4 ) if( CMD_ARGC() < 4 )
{ {
ALERT( at_console, "Usage: mp_enttools_blacklist <pattern> <per minute limit> <behaviour (0 - block, 1 - kick, 2 - ban)>\n" ); ALERT( at_console, "Usage: mp_enttools_blacklist <pattern> <per minute limit> <behaviour (0 - block, 1 - kick, 2 - ban)> <clear>\n" );
} }
entblacklist_t *node = (entblacklist_t *)malloc( sizeof( entblacklist_t ) ); entblacklist_t *node = (entblacklist_t *)malloc( sizeof( entblacklist_t ) );
@ -94,6 +95,7 @@ void Ent_AddToBlacklist_f( void )
node->pattern[32] = 0; node->pattern[32] = 0;
node->limit = atoi( CMD_ARGV(2) ); node->limit = atoi( CMD_ARGV(2) );
node->behaviour = atoi( CMD_ARGV( 3 ) ); node->behaviour = atoi( CMD_ARGV( 3 ) );
node->clear = !!atoi( CMD_ARGV( 4 ) );
entblacklist = node; entblacklist = node;
} }
@ -149,6 +151,7 @@ bool Ent_CheckCreate( edict_t *player, const char *classname )
if( !node->limit || ( p->gravgunmod_data.m_flEntScope + 1.0f / (float)node->limit > 1 ) ) if( !node->limit || ( p->gravgunmod_data.m_flEntScope + 1.0f / (float)node->limit > 1 ) )
{ {
// remove all created entities // remove all created entities
if( node->clear )
Ent_RunGC( false, true, GGM_GetPlayerID( player ) ); Ent_RunGC( false, true, GGM_GetPlayerID( player ) );
if( node->behaviour == 2 ) if( node->behaviour == 2 )
@ -518,7 +521,7 @@ void Ent_Fire_f( edict_t *player )
ent = g_engfuncs.pfnPEntityOfEntIndex( i ); ent = g_engfuncs.pfnPEntityOfEntIndex( i );
if( !Ent_IsValidEdict( ent )) if( !Ent_IsValidEdict( ent ))
{ {
// Ent_ClientPrintf( player, "Got invalid entity\n" ); Ent_ClientPrintf( player, "Got invalid entity\n" );
if( single ) if( single )
break; break;
continue; continue;
@ -530,35 +533,101 @@ void Ent_Fire_f( edict_t *player )
if( !Q_stricmpext( CMD_ARGV( 1 ), STRING( ent->v.targetname ) ) && !Q_stricmpext( CMD_ARGV( 1 ), STRING( ent->v.classname ) )) if( !Q_stricmpext( CMD_ARGV( 1 ), STRING( ent->v.targetname ) ) && !Q_stricmpext( CMD_ARGV( 1 ), STRING( ent->v.classname ) ))
continue; continue;
} }
const char *cmd = CMD_ARGV( 2 );
if( !stricmp( cmd, "help" ) )
{
Ent_ClientPrintf( player, "Availiavle commands:\n"
"Set fields:\n"
" (Only set entity field, does not call any functions)\n"
" health\n"
" gravity\n"
" movetype\n"
" solid\n"
" rendermode\n"
" rendercolor (vector)\n"
" renderfx\n"
" renderamt\n"
" hullmin (vector)\n"
" hullmax (vector)\n" );
Ent_ClientPrintf( player,
"Actions\n"
" rename: set entity targetname\n"
" settarget: set entity target (only targetnames)\n"
" setmodel: set entity model\n"
" set: set <key> <value> by server library\n"
" See game FGD to get list.\n"
" command takes two arguments\n");
Ent_ClientPrintf( player,
" touch: touch entity by current player.\n"
" use: use entity by current player.\n"
" movehere: place entity in player fov.\n"
" drop2floor: place entity to nearest floor surface\n"
" moveup: move entity to 25 units up\n");
Ent_ClientPrintf( player,
"Flags:\n"
" (Set/clear specified flag bit, arg is bit number)\n"
" setflag\n"
" clearflag\n"
" setspawnflag\n"
" clearspawnflag\n"
);
return;
}
if( !Ent_CheckFire( player, ent, CMD_ARGV( 2 ) ) ) if( !Ent_CheckFire( player, ent, CMD_ARGV( 2 ) ) )
continue; continue;
Ent_ClientPrintf( player, "entity %i\n", i ); Ent_ClientPrintf( player, "entity %i\n", i );
if( single && count > 0 )
break;
count++; count++;
if( !stricmp( CMD_ARGV( 2 ), "health" ) ) if( !stricmp( cmd, "health" ) )
{
ent->v.health = atoi( CMD_ARGV ( 3 ) ); ent->v.health = atoi( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "gravity" ) ) continue;
}
if( !stricmp( cmd, "gravity" ) )
{
ent->v.gravity = atof( CMD_ARGV ( 3 ) ); ent->v.gravity = atof( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "movetype" ) ) continue;
}
if( !stricmp( cmd, "movetype" ) )
{
ent->v.movetype = atoi( CMD_ARGV ( 3 ) ); ent->v.movetype = atoi( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "solid" ) ) continue;
}
if( !stricmp( cmd, "solid" ) )
{
ent->v.solid = atoi( CMD_ARGV ( 3 ) ); ent->v.solid = atoi( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "rename" ) ) continue;
}
if( !stricmp( cmd, "rename" ) )
{
ent->v.targetname = ALLOC_STRING( CMD_ARGV ( 3 ) ); ent->v.targetname = ALLOC_STRING( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "settarget" ) ) continue;
}
if( !stricmp( cmd, "settarget" ) )
{
ent->v.target = ALLOC_STRING( CMD_ARGV ( 3 ) ); ent->v.target = ALLOC_STRING( CMD_ARGV ( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "setmodel" ) ) continue;
}
if( !stricmp( cmd, "setmodel" ) )
{
SET_MODEL( ent, CMD_ARGV( 3 ) ); SET_MODEL( ent, CMD_ARGV( 3 ) );
else if( !stricmp( CMD_ARGV( 2 ), "set" ) ) continue;
}
if( !stricmp( cmd, "set" ) )
{ {
char keyname[256]; char keyname[256];
char value[256]; char value[256];
KeyValueData pkvd; KeyValueData pkvd;
if( CMD_ARGC() != 5 ) if( CMD_ARGC() != 5 )
return; continue;
pkvd.szClassName = (char*)STRING( ent->v.classname ); pkvd.szClassName = (char*)STRING( ent->v.classname );
strncpy( keyname, CMD_ARGV( 3 ), 256 ); strncpy( keyname, CMD_ARGV( 3 ), 256 );
strncpy( value, CMD_ARGV( 4 ), 256 ); strncpy( value, CMD_ARGV( 4 ), 256 );
@ -569,8 +638,9 @@ void Ent_Fire_f( edict_t *player )
DispatchKeyValue( ent, &pkvd ); DispatchKeyValue( ent, &pkvd );
if( pkvd.fHandled ) if( pkvd.fHandled )
Ent_ClientPrintf( player, "value set successfully!\n" ); Ent_ClientPrintf( player, "value set successfully!\n" );
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "touch" ) ) if( !stricmp( cmd, "touch" ) )
{ {
if( CMD_ARGC() == 4 ) if( CMD_ARGC() == 4 )
{ {
@ -580,8 +650,9 @@ void Ent_Fire_f( edict_t *player )
} }
else else
DispatchTouch( ent, player ); DispatchTouch( ent, player );
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "use" ) ) if( !stricmp( cmd, "use" ) )
{ {
if( CMD_ARGC() == 4 ) if( CMD_ARGC() == 4 )
{ {
@ -591,12 +662,19 @@ void Ent_Fire_f( edict_t *player )
} }
else else
DispatchUse( ent, player ); DispatchUse( ent, player );
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "movehere" ) ) if( !stricmp( cmd, "movehere" ) )
{
UTIL_SetOrigin( &ent->v, player->v.origin + Vector( 100 * cos( player->v.angles[1]/180*M_PI ), 100 * sin( player->v.angles[1]/180*M_PI), 25 ) ); UTIL_SetOrigin( &ent->v, player->v.origin + Vector( 100 * cos( player->v.angles[1]/180*M_PI ), 100 * sin( player->v.angles[1]/180*M_PI), 25 ) );
else if( !stricmp( CMD_ARGV( 2 ), "drop2floor" ) ) continue;
}
if( !stricmp( cmd, "drop2floor" ) )
{
DROP_TO_FLOOR( ent ); DROP_TO_FLOOR( ent );
else if( !stricmp( CMD_ARGV( 2 ), "moveup" ) ) continue;
}
if( !stricmp( cmd, "moveup" ) )
{ {
float dist = 25; float dist = 25;
@ -607,29 +685,32 @@ void Ent_Fire_f( edict_t *player )
if( CMD_ARGC() >= 5 ) if( CMD_ARGC() >= 5 )
ent->v.origin = ent->v.origin + Vector( cos( player->v.angles[1]/180*M_PI ), sin( player->v.angles[1]/180*M_PI), 0 ) * atof( CMD_ARGV( 4 ) ); ent->v.origin = ent->v.origin + Vector( cos( player->v.angles[1]/180*M_PI ), sin( player->v.angles[1]/180*M_PI), 0 ) * atof( CMD_ARGV( 4 ) );
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "becomeowner" ) ) if( !stricmp( cmd, "becomeowner" ) )
{ {
if( CMD_ARGC() == 4 ) if( CMD_ARGC() == 4 )
ent->v.owner = Ent_FindSingle( player, CMD_ARGV( 3 ) ); ent->v.owner = Ent_FindSingle( player, CMD_ARGV( 3 ) );
else else
ent->v.owner = player; ent->v.owner = player;
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "becomeenemy" ) ) if( !stricmp( cmd, "becomeenemy" ) )
{ {
if( CMD_ARGC() == 4 ) if( CMD_ARGC() == 4 )
ent->v.enemy = Ent_FindSingle( player, CMD_ARGV( 3 ) ); ent->v.enemy = Ent_FindSingle( player, CMD_ARGV( 3 ) );
else else
ent->v.enemy = player; ent->v.enemy = player;
continue;
} }
else if( !stricmp( CMD_ARGV( 2 ), "becomeaiment" ) ) else if( !stricmp( cmd, "becomeaiment" ) )
{ {
if( CMD_ARGC() == 4 ) if( CMD_ARGC() == 4 )
ent->v.aiment= Ent_FindSingle( player, CMD_ARGV( 3 ) ); ent->v.aiment= Ent_FindSingle( player, CMD_ARGV( 3 ) );
else else
ent->v.aiment = player; ent->v.aiment = player;
} }
else if( !stricmp( CMD_ARGV( 2 ), "hullmin" ) ) else if( !stricmp( cmd, "hullmin" ) )
{ {
if( CMD_ARGC() != 6 ) if( CMD_ARGC() != 6 )
return; return;
@ -637,7 +718,7 @@ void Ent_Fire_f( edict_t *player )
ent->v.mins[1] = atof( CMD_ARGV( 4 ) ); ent->v.mins[1] = atof( CMD_ARGV( 4 ) );
ent->v.mins[2] = atof( CMD_ARGV( 5 ) ); ent->v.mins[2] = atof( CMD_ARGV( 5 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "hullmax" ) ) else if( !stricmp( cmd, "hullmax" ) )
{ {
if( CMD_ARGC() != 6 ) if( CMD_ARGC() != 6 )
return; return;
@ -645,7 +726,7 @@ void Ent_Fire_f( edict_t *player )
ent->v.maxs[1] = atof( CMD_ARGV( 4 ) ); ent->v.maxs[1] = atof( CMD_ARGV( 4 ) );
ent->v.maxs[2] = atof( CMD_ARGV( 5 ) ); ent->v.maxs[2] = atof( CMD_ARGV( 5 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "rendercolor" ) ) else if( !stricmp( cmd, "rendercolor" ) )
{ {
if( CMD_ARGC() != 6 ) if( CMD_ARGC() != 6 )
return; return;
@ -653,90 +734,54 @@ void Ent_Fire_f( edict_t *player )
ent->v.rendercolor[1] = atof( CMD_ARGV( 4 ) ); ent->v.rendercolor[1] = atof( CMD_ARGV( 4 ) );
ent->v.rendercolor[2] = atof( CMD_ARGV( 5 ) ); ent->v.rendercolor[2] = atof( CMD_ARGV( 5 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "renderamt" ) ) else if( !stricmp( cmd, "renderamt" ) )
{ {
ent->v.renderamt = atof( CMD_ARGV( 3 ) ); ent->v.renderamt = atof( CMD_ARGV( 3 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "renderfx" ) ) else if( !stricmp( cmd, "renderfx" ) )
{ {
ent->v.renderfx = atoi( CMD_ARGV( 3 ) ); ent->v.renderfx = atoi( CMD_ARGV( 3 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "rendermode" ) ) else if( !stricmp( cmd, "rendermode" ) )
{ {
ent->v.rendermode = atoi( CMD_ARGV( 3 ) ); ent->v.rendermode = atoi( CMD_ARGV( 3 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "angles" ) ) else if( !stricmp( cmd, "angles" ) )
{ {
ent->v.angles[0] = atof( CMD_ARGV( 3 ) ); ent->v.angles[0] = atof( CMD_ARGV( 3 ) );
ent->v.angles[1] = atof( CMD_ARGV( 4 ) ); ent->v.angles[1] = atof( CMD_ARGV( 4 ) );
ent->v.angles[2] = atof( CMD_ARGV( 5 ) ); ent->v.angles[2] = atof( CMD_ARGV( 5 ) );
} }
else if( !stricmp( CMD_ARGV( 2 ), "setflag" ) ) else if( !stricmp( cmd, "setflag" ) )
{ {
ent->v.flags |= 1U << atoi( CMD_ARGV ( 3 ) ); ent->v.flags |= 1U << atoi( CMD_ARGV ( 3 ) );
Ent_ClientPrintf( player, "flags set to 0x%x\n", ent->v.flags ); Ent_ClientPrintf( player, "flags set to 0x%x\n", ent->v.flags );
} }
else if( !stricmp( CMD_ARGV( 2 ), "clearflag" ) ) else if( !stricmp( cmd, "clearflag" ) )
{ {
ent->v.flags &= ~( 1U << atoi( CMD_ARGV ( 3 ) ) ); ent->v.flags &= ~( 1U << atoi( CMD_ARGV ( 3 ) ) );
Ent_ClientPrintf( player, "flags set to 0x%x\n", ent->v.flags ); Ent_ClientPrintf( player, "flags set to 0x%x\n", ent->v.flags );
} }
else if( !stricmp( CMD_ARGV( 2 ), "setspawnflag" ) ) else if( !stricmp( cmd, "setspawnflag" ) )
{ {
ent->v.spawnflags |= 1U << atoi( CMD_ARGV ( 3 ) ); ent->v.spawnflags |= 1U << atoi( CMD_ARGV ( 3 ) );
Ent_ClientPrintf( player, "spawnflags set to 0x%x\n", ent->v.spawnflags ); Ent_ClientPrintf( player, "spawnflags set to 0x%x\n", ent->v.spawnflags );
} }
else if( !stricmp( CMD_ARGV( 2 ), "clearspawnflag" ) ) else if( !stricmp( cmd, "clearspawnflag" ) )
{ {
ent->v.spawnflags &= ~( 1U << atoi( CMD_ARGV ( 3 ) ) ); ent->v.spawnflags &= ~( 1U << atoi( CMD_ARGV ( 3 ) ) );
Ent_ClientPrintf( player, "spawnflags set to 0x%x\n", ent->v.flags ); Ent_ClientPrintf( player, "spawnflags set to 0x%x\n", ent->v.flags );
} }
else if( !stricmp( CMD_ARGV( 2 ), "help" ) )
{
Ent_ClientPrintf( player, "Availiavle commands:\n"
"Set fields:\n"
" (Only set entity field, does not call any functions)\n"
" health\n"
" gravity\n"
" movetype\n"
" solid\n"
" rendermode\n"
" rendercolor (vector)\n"
" renderfx\n"
" renderamt\n"
" hullmin (vector)\n"
" hullmax (vector)\n"
"Actions\n"
" rename: set entity targetname\n"
" settarget: set entity target (only targetnames)\n"
" setmodel: set entity model\n"
" set: set <key> <value> by server library\n"
" See game FGD to get list.\n"
" command takes two arguments\n"
" touch: touch entity by current player.\n"
" use: use entity by current player.\n"
" movehere: place entity in player fov.\n"
" drop2floor: place entity to nearest floor surface\n"
" moveup: move entity to 25 units up\n"
"Flags:\n"
" (Set/clear specified flag bit, arg is bit number)\n"
" setflag\n"
" clearflag\n"
" setspawnflag\n"
" clearspawnflag\n"
);
return;
}
else else
{ {
Ent_ClientPrintf( player, "Unknown command %s!\nUse \"ent_fire 0 help\" to list commands.\n", CMD_ARGV( 2 ) ); Ent_ClientPrintf( player, "Unknown command %s!\nUse \"ent_fire 0 help\" to list commands.\n", cmd );
return; return;
} }
if( single ) if( single )
break; break;
} }
} }
/* /*
=============== ===============
Ent_Create_f Ent_Create_f
@ -855,8 +900,10 @@ void Ent_Create_f( edict_t *player )
CBaseEntity *entity = CBaseEntity::Instance( ent ); CBaseEntity *entity = CBaseEntity::Instance( ent );
if( entity ) if( entity )
{ {
const char *plid = GGM_GetPlayerID( player );
entity->enttools_data.enttools = true; entity->enttools_data.enttools = true;
strcpy( entity->enttools_data.ownerid, GGM_GetPlayerID( player ) ); if( plid );
strcpy( entity->enttools_data.ownerid, plid );
} }
} }
typedef struct ucmd_s typedef struct ucmd_s
@ -879,17 +926,21 @@ bool Ent_ProcessClientCommand( edict_t *player )
{ {
ucmd_t *u; ucmd_t *u;
if( !mp_enttools_enable.value ) if( !mp_enttools_enable.value )
return false; return false;
CBaseEntity *pl = CBaseEntity::Instance( player );
if( !pl || !pl->IsPlayer() )
return false;
for( u = enttoolscmds; u->name; u++ ) for( u = enttoolscmds; u->name; u++ )
{ {
if( !strcmp( CMD_ARGV( 0 ), u->name )) if( !strcmp( CMD_ARGV( 0 ), u->name ))
{ {
ALERT( at_console, "enttools->%s(): %s\n", u->name, CMD_ARGS() ); ALERT( at_console, "enttools->%s(): %s\n", u->name, CMD_ARGS() );
ALERT( at_logged, "\"%s<%i><%s><>\" performed: %s\n", STRING(player->v.netname), ALERT( at_logged, "\"%s<%i><%s><%s>\" performed: %s\n", STRING(player->v.netname),
GETPLAYERUSERID(player), GETPLAYERAUTHID(player), g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( player ), "ip" ), CMD_ARGS() ); GETPLAYERUSERID(player), GETPLAYERAUTHID(player), g_engfuncs.pfnInfoKeyValue( g_engfuncs.pfnGetInfoKeyBuffer( player ), "ip" ), CMD_ARGS() );
if( u->func ) u->func( player ); if( u->func ) u->func( player );

Loading…
Cancel
Save