mirror of
https://github.com/UberGames/rpgxEF.git
synced 2024-11-10 15:21:34 +00:00
Merge remote-tracking branch 'origin/devel' into locations
This commit is contained in:
commit
0e2a8a30f8
16 changed files with 282 additions and 125 deletions
|
@ -1561,7 +1561,7 @@ static gender_t G_ParseAnimationFileSex( const char *filename) {
|
|||
char *text_p;
|
||||
int len;
|
||||
char *token;
|
||||
char text[20000];
|
||||
char text[20000]; // TODO move to heap?
|
||||
fileHandle_t f;
|
||||
char animfile[MAX_QPATH];
|
||||
|
||||
|
@ -1703,7 +1703,7 @@ char* BG_RegisterRace( const char *name ) {
|
|||
qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {
|
||||
fileHandle_t f;
|
||||
int file_len;
|
||||
char charText[20000];
|
||||
char charText[20000]; // TODO move to heap?
|
||||
char* textPtr;
|
||||
char* token;
|
||||
int i = 0;
|
||||
|
@ -1762,6 +1762,7 @@ qboolean BG_ParseRankNames( char* fileName, rankNames_t rankNames[] ) {
|
|||
/* If we hit an open brace (ie, assuming we hit the start of a new rank cell) */
|
||||
if ( !Q_stricmpn( token, "{", 1 ) ) {
|
||||
while ( 1 ) {
|
||||
|
||||
token = COM_Parse( &textPtr );
|
||||
if( !token[0] ) {
|
||||
break;
|
||||
|
|
|
@ -1750,7 +1750,7 @@ void G_Client_Begin( int clientNum, qboolean careAboutWarmup, qboolean isBot, qb
|
|||
int len;
|
||||
fileHandle_t file;
|
||||
char *p, *q;
|
||||
char buf[16000];
|
||||
char buf[16000]; // TODO move to heap ?
|
||||
|
||||
len = trap_FS_FOpenFile( rpg_motdFile.string, &file, FS_READ );
|
||||
if (!file || !len) {
|
||||
|
@ -1908,6 +1908,7 @@ void G_Client_Spawn(gentity_t *ent, int rpgx_spawn, qboolean fromDeath ) {
|
|||
pclass_t pClass = 0;//PC_NOCLASS;
|
||||
int cCDT = 0;
|
||||
int clientNum;
|
||||
pclass_t oClass;
|
||||
|
||||
index = ent - g_entities;
|
||||
client = ent->client;
|
||||
|
@ -2023,7 +2024,7 @@ void G_Client_Spawn(gentity_t *ent, int rpgx_spawn, qboolean fromDeath ) {
|
|||
// health will count down towards max_health
|
||||
ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] * 1.25;
|
||||
|
||||
pclass_t oClass = client->sess.sessionClass;
|
||||
oClass = client->sess.sessionClass;
|
||||
|
||||
if ( oClass != client->sess.sessionClass )
|
||||
{//need to send the class change
|
||||
|
|
|
@ -300,6 +300,10 @@ static void Cmd_Give_f( gentity_t *ent ) {
|
|||
for ( i = bg_numGiveItems - 1; i > -1; i-- ) {
|
||||
item = &bg_giveItem[i];
|
||||
|
||||
if(item == NULL) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( arg, item->consoleName ) ) {
|
||||
break;
|
||||
}
|
||||
|
@ -317,6 +321,10 @@ static void Cmd_Give_f( gentity_t *ent ) {
|
|||
|
||||
//Fuck this. Why does ioEF crash if you don't break a case statement with code in it? :S
|
||||
|
||||
if(item == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch ( item->giveType ) {
|
||||
case TYPE_ALL:
|
||||
targEnt->health = ps->stats[STAT_MAX_HEALTH];
|
||||
|
@ -1566,17 +1574,17 @@ static void Cmd_SayArea( gentity_t *ent, char* text)
|
|||
|
||||
OtherPlayer = &g_entities[i]; //Point OtherPlayer to next player
|
||||
|
||||
//Send message to admins warning about command being used.
|
||||
//TiM - since double spamming is annoying, ensure that the target admin wants this alert
|
||||
if ( !OtherPlayer->client->noAdminChat )
|
||||
G_SayTo( ent, OtherPlayer, SAY_ADMIN, COLOR_CYAN, va("%s ^7said to area: ", pers->netname ), text ); //^2%s
|
||||
|
||||
//Check is OtherPlayer is valid
|
||||
if ( !OtherPlayer || !OtherPlayer->inuse || !OtherPlayer->client )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
//Send message to admins warning about command being used.
|
||||
//TiM - since double spamming is annoying, ensure that the target admin wants this alert
|
||||
if ( !OtherPlayer->client->noAdminChat )
|
||||
G_SayTo( ent, OtherPlayer, SAY_ADMIN, COLOR_CYAN, va("%s ^7said to area: ", pers->netname ), text ); //^2%s
|
||||
|
||||
//TiM - I have a better solution. the trap_inPVS function lets u see if two points are within the same Vis cluster
|
||||
//in the BSP tree. That should mean as long as they're in the same room, regardless if they can see each other or not,
|
||||
//they'll get the message
|
||||
|
@ -2220,6 +2228,10 @@ static void Cmd_ForceKill_f( gentity_t *ent ) {
|
|||
}
|
||||
} // end iterations
|
||||
|
||||
if(target == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
Com_sprintf (send, sizeof(send), "%s ^7forced %s^7's death", ent->client->pers.netname, target->client->pers.netname);
|
||||
|
||||
for (j = 0; j < MAX_CLIENTS - 1; j++) {
|
||||
|
@ -3725,7 +3737,7 @@ static void Cmd_EntList_f ( gentity_t *ent ) {
|
|||
Com_sprintf( entBuffer, sizeof( entBuffer ), "ClassName: '%s', ID: %i\n", mapEnt->classname, i);
|
||||
}
|
||||
|
||||
if ( strlen(mainBuffer) + strlen(entBuffer) > sizeof( mainBuffer ) ) {
|
||||
if ( strlen(mainBuffer) + strlen(entBuffer) >= sizeof( mainBuffer ) ) {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
|
@ -5262,7 +5274,7 @@ static void Cmd_MapsList_f( gentity_t *ent )
|
|||
continue;
|
||||
}
|
||||
|
||||
if ( strlen(mapList) + len + 20 > sizeof( mapList ) )
|
||||
if ( strlen(mapList) + len + 20 >= sizeof( mapList ) )
|
||||
break;
|
||||
|
||||
Q_strcat( mapList, sizeof( mapList ), filePtr );
|
||||
|
|
|
@ -1113,7 +1113,7 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
|
|||
|
||||
if ( client )
|
||||
{
|
||||
if ( client->noclip ) {
|
||||
if ( client == NULL || client->noclip ) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1628,6 +1628,8 @@ void plasma_link( gentity_t *ent )
|
|||
//------------------------------------------
|
||||
void SP_fx_plasma( gentity_t *ent )
|
||||
{
|
||||
int t;
|
||||
|
||||
if (!ent->startRGBA)
|
||||
{
|
||||
ent->startRGBA[0] = 100;
|
||||
|
@ -1644,7 +1646,6 @@ void SP_fx_plasma( gentity_t *ent )
|
|||
G_SpawnInt( "damage", "0", &ent->damage );
|
||||
|
||||
// Convert from range of 0-255 to 0-1
|
||||
int t;
|
||||
for (t=0; t < 3; t++)
|
||||
{
|
||||
ent->startRGBA[t] = ent->startRGBA[t] / 255;
|
||||
|
@ -2014,6 +2015,8 @@ void borg_energy_beam_link( gentity_t *ent )
|
|||
//------------------------------------------
|
||||
void SP_fx_borg_energy_beam( gentity_t *ent )
|
||||
{
|
||||
int t;
|
||||
|
||||
G_SpawnFloat( "radius", "30", &ent->distance );
|
||||
G_SpawnFloat( "speed", "100", &ent->speed );
|
||||
if (!ent->startRGBA)
|
||||
|
@ -2023,7 +2026,6 @@ void SP_fx_borg_energy_beam( gentity_t *ent )
|
|||
}
|
||||
|
||||
// Convert from range of 0-255 to 0-1
|
||||
int t;
|
||||
for (t=0; t < 4; t++)
|
||||
{
|
||||
ent->startRGBA[t] = ent->startRGBA[t] / 255;
|
||||
|
|
|
@ -2621,6 +2621,7 @@ void G_RunThink (gentity_t *ent) {
|
|||
ent->nextthink = 0;
|
||||
if (!ent->think) {
|
||||
G_Error ( "NULL ent->think");
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef G_LUA
|
||||
|
|
|
@ -607,10 +607,12 @@ void Svcmd_EntityList_f (void) {
|
|||
gentity_t *check;
|
||||
char arg[MAX_QPATH*4];
|
||||
int length = 0;
|
||||
qboolean args = qfalse;
|
||||
|
||||
if(trap_Argc() > 1) {
|
||||
trap_Argv(1, arg, sizeof(arg));
|
||||
length = strlen(arg);
|
||||
args = qtrue;
|
||||
}
|
||||
|
||||
check = g_entities+1;
|
||||
|
@ -618,7 +620,7 @@ void Svcmd_EntityList_f (void) {
|
|||
if ( !check->inuse ) {
|
||||
continue;
|
||||
}
|
||||
if(!arg[0]) {
|
||||
if(args == qfalse) {
|
||||
if ( check->classname && Q_stricmpn(check->classname, "noclass", 7) && Q_stricmpn(check->classname, "bodyque", 7) ) {
|
||||
G_Printf("%3i:", e);
|
||||
switch ( check->s.eType ) {
|
||||
|
|
|
@ -127,8 +127,10 @@ void trap_Trace( trace_t *results, const vec3_t start, const vec3_t mins, const
|
|||
syscall( G_TRACE, results, start, mins, maxs, end, passEntityNum, contentmask );
|
||||
if(g_developer.integer & 2) { // Debug trace
|
||||
vec3_t s;
|
||||
gentity_t* tmp;
|
||||
|
||||
VectorCopy(start, s);
|
||||
gentity_t* tmp = G_TempEntity(s, EV_DEBUG_TRACE);
|
||||
tmp = G_TempEntity(s, EV_DEBUG_TRACE);
|
||||
VectorCopy(end, tmp->s.origin2);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1644,6 +1644,10 @@ void SP_target_turbolift ( gentity_t *self )
|
|||
char mapRoute[MAX_QPATH];
|
||||
char serverInfo[MAX_TOKEN_CHARS];
|
||||
|
||||
if(self == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
//cache the moving sounds
|
||||
G_SpawnString( "soundLoop", "sound/movers/plats/turbomove.wav", &loopSound );
|
||||
G_SpawnString( "soundEnd", "sound/movers/plats/turbostop.wav", &endSound );
|
||||
|
|
|
@ -364,7 +364,7 @@ void Use_target_push( gentity_t *self, gentity_t *other, gentity_t *activator )
|
|||
}
|
||||
|
||||
/* RPG-X: J2J noclip use */
|
||||
if ( activator->client->ps.pm_type != PM_NORMAL || activator->client->ps.pm_type != PM_NOCLIP) {
|
||||
if ( (activator->client->ps.pm_type != PM_NORMAL) || (activator->client->ps.pm_type != PM_NOCLIP)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -1098,11 +1098,13 @@ void laser_arm_start (gentity_t *base)
|
|||
{
|
||||
vec3_t armAngles;
|
||||
vec3_t headAngles;
|
||||
gentity_t *arm;
|
||||
gentity_t *head;
|
||||
|
||||
base->think = 0;
|
||||
/* We're the base, spawn the arm and head */
|
||||
gentity_t *arm = G_Spawn();
|
||||
gentity_t *head = G_Spawn();
|
||||
arm = G_Spawn();
|
||||
head = G_Spawn();
|
||||
|
||||
VectorCopy( base->s.angles, armAngles );
|
||||
VectorCopy( base->s.angles, headAngles );
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<AdditionalIncludeDirectories>lua\include;mysql;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>__WIN32__;WIN32;_DEBUG;_WINDOWS;DEBUG;QAGAME;XTRA;G_LUA;CG_LUA;SQL=1;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<PreprocessorDefinitions>__WIN32__;WIN32;_DEBUG;_WINDOWS;DEBUG;QAGAME;XTRA;G_LUA;CG_LUA;SQL=1;LUA_COMPAT_ALL;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<StringPooling>false</StringPooling>
|
||||
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
|
||||
<BufferSecurityCheck>false</BufferSecurityCheck>
|
||||
|
@ -89,7 +89,7 @@
|
|||
<Culture>0x0409</Culture>
|
||||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalDependencies>winmm.lib;lua52.lib;mysqlclient.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>C:\Program Files\Raven\Star Trek Voyager Elite Force\RPG-X2\qagamex86.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>.\game.def</ModuleDefinitionFile>
|
||||
|
@ -475,6 +475,7 @@
|
|||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">WIN32;NDEBUG;_WINDOWS</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<ClCompile Include="lua_vector.c" />
|
||||
<ClCompile Include="sqlite3.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ai_chat.h" />
|
||||
|
@ -536,6 +537,7 @@
|
|||
<ClInclude Include="match.h" />
|
||||
<ClInclude Include="md5.h" />
|
||||
<ClInclude Include="q_shared.h" />
|
||||
<ClInclude Include="sqlite3.h" />
|
||||
<ClInclude Include="surfaceflags.h" />
|
||||
<ClInclude Include="syn.h" />
|
||||
</ItemGroup>
|
||||
|
|
|
@ -282,6 +282,9 @@
|
|||
<ClCompile Include="md5.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="sqlite3.c">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="ai_chat.h">
|
||||
|
@ -467,6 +470,9 @@
|
|||
<ClInclude Include="md5.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="sqlite3.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="game.def">
|
||||
|
|
|
@ -78,17 +78,31 @@ static int Entity_MMBRefit(lua_State * L)
|
|||
// returns a target entity of ent
|
||||
static int Entity_GetTarget(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
gentity_t *t = NULL;
|
||||
lent_t* lent = NULL;
|
||||
gentity_t* t = NULL;
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.GetTarget");
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
t = G_PickTarget(lent->e->target);
|
||||
if(!lent || !lent->e || !t) {
|
||||
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.GetTarget - entity NULL");
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
t = G_PickTarget(lent->e->target);
|
||||
if(t == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.GetTarget - target NULL");
|
||||
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Lua_PushEntity(L, t);
|
||||
|
||||
LUA_DEBUG("END - entity.GetTarget");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -97,16 +111,24 @@ static int Entity_GetTarget(lua_State * L)
|
|||
// This is the only failsafe way to find brush entities as the
|
||||
// entity number is different when you load a map local or join a server.
|
||||
static int Entity_FindBModel(lua_State *L) {
|
||||
gentity_t *ent;
|
||||
gentity_t* ent = NULL;
|
||||
int bmodel;
|
||||
char tmp[MAX_QPATH];
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.FindBModel");
|
||||
|
||||
bmodel = luaL_checkint(L, 1);
|
||||
ent = G_Find(NULL, FOFS(model), va("*%i", bmodel));
|
||||
if(!ent)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
Lua_PushEntity(L, ent);
|
||||
sprintf(tmp, "*%d", bmodel);
|
||||
ent = G_Find(NULL, FOFS(model), tmp);
|
||||
|
||||
if(ent == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.FindBModel - entity NULL");
|
||||
lua_pushnil(L);
|
||||
} else {
|
||||
Lua_PushEntity(L, ent);
|
||||
}
|
||||
|
||||
LUA_DEBUG("END - entity.FindBModel");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -114,16 +136,22 @@ static int Entity_FindBModel(lua_State *L) {
|
|||
// Returns the entity with the entity number entnum.
|
||||
static int Entity_FindNumber(lua_State * L)
|
||||
{
|
||||
int entnum;
|
||||
gentity_t *ent;
|
||||
int entnum;
|
||||
gentity_t* ent = NULL;
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.FindNumber");
|
||||
|
||||
entnum = luaL_checknumber(L, 1);
|
||||
ent = &g_entities[entnum];
|
||||
if(!ent || !ent->inuse)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
Lua_PushEntity(L, ent);
|
||||
|
||||
if(ent == NULL || ent->inuse == qfalse) {
|
||||
LUA_DEBUG("ERROR - entity.FindNumber - entity NULL");
|
||||
lua_pushnil(L);
|
||||
} else {
|
||||
Lua_PushEntity(L, ent);
|
||||
}
|
||||
|
||||
LUA_DEBUG("END - entity.FindNumber");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -131,14 +159,20 @@ static int Entity_FindNumber(lua_State * L)
|
|||
// Returns the first entity found that has a targetname of targetname.
|
||||
static int Entity_Find(lua_State * L)
|
||||
{
|
||||
gentity_t *t = NULL;
|
||||
gentity_t* t = NULL;
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.Find");
|
||||
|
||||
t = G_Find(t, FOFS(targetname), (char *)luaL_checkstring(L, 1));
|
||||
if(!t)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
Lua_PushEntity(L, t);
|
||||
|
||||
if(t == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.Find - target NULL");
|
||||
lua_pushnil(L);
|
||||
} else {
|
||||
Lua_PushEntity(L, t);
|
||||
}
|
||||
|
||||
LUA_DEBUG("END - entity.Find");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -149,7 +183,7 @@ static int Entity_Find(lua_State * L)
|
|||
static int Entity_FindMMB(lua_State * L)
|
||||
{
|
||||
gentity_t *t = NULL, *MMB = NULL;
|
||||
vec_t *vec, *origin;
|
||||
vec_t *vec = NULL, *origin = NULL;
|
||||
|
||||
vec = Lua_GetVector(L, 2);
|
||||
|
||||
|
@ -158,53 +192,81 @@ static int Entity_FindMMB(lua_State * L)
|
|||
if(vec[0] == origin[0] && vec[1] == origin[1] && vec[2] == origin[2]){
|
||||
t = MMB;
|
||||
break;
|
||||
}else{
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(!t)
|
||||
if(t == NULL) {
|
||||
lua_pushnil(L);
|
||||
else
|
||||
} else {
|
||||
Lua_PushEntity(L, t);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// entity.Use(entity ent)
|
||||
// Uses ent.
|
||||
// returns succes or fail
|
||||
static int Entity_Use(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.Use");
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || !lent->e || !lent->e->use) return 1;
|
||||
if(lent == NULL || lent->e == NULL || lent->e->use == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.Use - entity NULL");
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(lent->e->luaUse)
|
||||
if(lent->e->luaUse != NULL) {
|
||||
LUA_DEBUG("INFO - entity.Use - calling entity->luaUse");
|
||||
LuaHook_G_EntityUse(lent->e->luaUse, lent->e-g_entities, lent->e-g_entities, lent->e-g_entities);
|
||||
}
|
||||
lent->e->use(lent->e, NULL, lent->e);
|
||||
|
||||
lua_pushboolean(L, qtrue);
|
||||
LUA_DEBUG("END - entity.Use");
|
||||
return 1;
|
||||
}
|
||||
|
||||
// entity.Teleport(entity client, entity target)
|
||||
// Teleports client to target's position
|
||||
// returns success or fail
|
||||
static int Entity_Teleport(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t *target;
|
||||
lent_t* lent = NULL;;
|
||||
lent_t* target = NULL;
|
||||
|
||||
LUA_DEBUG("BEGIN - entity.Teleport");
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
target = Lua_GetEntity(L, 2);
|
||||
|
||||
if(!lent || !lent->e)
|
||||
return 1;
|
||||
if(!target || !target->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.Teleport - entity NULL");
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(lent->e->client)
|
||||
if(target == NULL || target->e == NULL) {
|
||||
LUA_DEBUG("ERROR - entity.Teleport - target NULL");
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(lent->e->client != NULL) {
|
||||
LUA_DEBUG("INFO - entity.Teleport - calling TeleportPlayer");
|
||||
TeleportPlayer(lent->e, target->e->s.origin, target->e->s.angles, TP_NORMAL);
|
||||
lua_pushboolean(L, qtrue);
|
||||
} else {
|
||||
lua_pushboolean(L, qfalse);
|
||||
}
|
||||
|
||||
LUA_DEBUG("END - entity.Teleport");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -213,15 +275,21 @@ static int Entity_Teleport(lua_State * L)
|
|||
// Checks if an entity is a rocket.
|
||||
static int Entity_IsRocket(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
qboolean rocket = qfalse;
|
||||
lent_t* lent = NULL;
|
||||
qboolean rocket = qfalse;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(lent->e && !Q_stricmp(lent->e->classname, "rocket"))
|
||||
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Q_stricmp(lent->e->classname, "rocket")) {
|
||||
rocket = qtrue;
|
||||
}
|
||||
|
||||
lua_pushboolean(L, (int)rocket);
|
||||
|
||||
lua_pushboolean(L, rocket);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -229,15 +297,21 @@ static int Entity_IsRocket(lua_State * L)
|
|||
// Checks if an entity is a grenade.
|
||||
static int Entity_IsGrenade(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
qboolean grenade = qfalse;
|
||||
lent_t* lent = NULL;
|
||||
qboolean grenade = qfalse;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(Q_stricmp(lent->e->classname, "grenade"))
|
||||
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Q_stricmp(lent->e->classname, "grenade")) {
|
||||
grenade = qtrue;
|
||||
}
|
||||
|
||||
lua_pushboolean(L, grenade);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -246,11 +320,16 @@ static int Entity_IsGrenade(lua_State * L)
|
|||
// If no new entity can be spawned nil is returned.
|
||||
static int Entity_Spawn(lua_State * L)
|
||||
{
|
||||
gentity_t *ent;
|
||||
gentity_t* ent = NULL;
|
||||
|
||||
ent = G_Spawn();
|
||||
Lua_PushEntity(L, ent);
|
||||
|
||||
if(ent == NULL) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
Lua_PushEntity(L, ent);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -258,13 +337,14 @@ static int Entity_Spawn(lua_State * L)
|
|||
// returns the entities index number
|
||||
static int Entity_GetNumber(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || !lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushinteger(L, -1);
|
||||
else
|
||||
} else {
|
||||
lua_pushinteger(L, lent->e - g_entities);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
@ -273,17 +353,16 @@ static int Entity_GetNumber(lua_State * L)
|
|||
// Checks if an entity is a client
|
||||
static int Entity_IsClient(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || !lent->e) {
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushboolean(L, 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_pushboolean(L, lent->e->client != NULL);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -291,33 +370,35 @@ static int Entity_IsClient(lua_State * L)
|
|||
// Returns the display name of a client
|
||||
static int Entity_GetClientName(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || !lent->e || !lent->e->classname) {
|
||||
if(lent == NULL || lent->e == NULL || lent->e->classname == NULL) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lua_pushstring(L, lent->e->client->pers.netname);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Entity_Print(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
int i;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
int n = lua_gettop(L);
|
||||
lent_t* lent = NULL;
|
||||
int i;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
int n = lua_gettop(L);
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent|| !lent->e) return 1;
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
return luaL_error(L, "\'Print\' must be called on an client entity.");
|
||||
}
|
||||
|
||||
if(!lent->e->client)
|
||||
return luaL_error(L, "\'Print\' must be used with a client entity");
|
||||
if(lent->e->client == NULL) {
|
||||
return luaL_error(L, "\'Print\' must be called on an client entity.");
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
|
@ -331,8 +412,9 @@ static int Entity_Print(lua_State * L)
|
|||
lua_call(L, 1, 1);
|
||||
s = lua_tostring(L, -1);
|
||||
|
||||
if(s == NULL)
|
||||
if(s == NULL) {
|
||||
return luaL_error(L, "\'tostring\' must return a string to \'print\'");
|
||||
}
|
||||
|
||||
Q_strcat(buf, sizeof(buf), s);
|
||||
|
||||
|
@ -340,23 +422,25 @@ static int Entity_Print(lua_State * L)
|
|||
}
|
||||
|
||||
trap_SendServerCommand(lent->e - g_entities, va("print \"%s\n\"", buf));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int Entity_CenterPrint(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
int i;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
int n = lua_gettop(L);
|
||||
lent_t *lent = NULL;
|
||||
int i;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
int n = lua_gettop(L);
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || !lent->e) return 1;
|
||||
|
||||
if(!lent->e->client)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
return luaL_error(L, "\'CenterPrint\' must be used with a client entity");
|
||||
}
|
||||
|
||||
if(lent->e->client == NULL) {
|
||||
return luaL_error(L, "\'CenterPrint\' must be used with a client entity");
|
||||
}
|
||||
|
||||
memset(buf, 0, sizeof(buf));
|
||||
|
||||
|
@ -387,14 +471,15 @@ extern qboolean G_ParseField(const char *key, const char *value, gentity_t *ent)
|
|||
// entity.SetKeyValue(entity ent, string key, string value)
|
||||
// Sets a key of an entity to a value
|
||||
static int Entity_SetKeyValue(lua_State * L) {
|
||||
lent_t *lent;
|
||||
char *key, *value;
|
||||
lent_t* lent = NULL;
|
||||
char* key = NULL;
|
||||
char* value = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
key = (char *)luaL_checkstring(L, 2);
|
||||
value = (char *)luaL_checkstring(L, 3);
|
||||
|
||||
if(!lent || !lent->e || !key[0] || !value[0]) {
|
||||
if(lent == NULL || lent->e == NULL || key == NULL || value == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
@ -407,28 +492,33 @@ static int Entity_SetKeyValue(lua_State * L) {
|
|||
// Returns the classname of an entity
|
||||
static int Entity_GetClassName(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || !lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushnil(L);
|
||||
else
|
||||
} else {
|
||||
lua_pushstring(L, lent->e->classname);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// entity.SetClassname(entity ent, string name)
|
||||
// Sets the Classname of an entity to name
|
||||
// Returns success or fail
|
||||
static int Entity_SetClassName(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || !lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
lent->e->classname = (char *)luaL_checkstring(L, 2);
|
||||
}
|
||||
|
||||
lent->e->classname = (char *)luaL_checkstring(L, 2);
|
||||
lua_pushboolean(L, qtrue);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -436,32 +526,40 @@ static int Entity_SetClassName(lua_State * L)
|
|||
// Returns the targetname of an entity
|
||||
static int Entity_GetTargetName(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || !lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushnil(L);
|
||||
else
|
||||
} else {
|
||||
lua_pushstring(L, lent->e->targetname);
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
// entity.Rotate(entity ent, vector dir)
|
||||
// Rotates an entity in the specified directions
|
||||
// Returns success or fail
|
||||
static int Entity_Rotate(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
vec_t *vec;
|
||||
lent_t* lent = NULL;
|
||||
vec_t* vec = NULL;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
vec = Lua_GetVector(L, 2);
|
||||
|
||||
if(lent == NULL || lent->e == NULL || vec == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
lent->e->s.apos.trType = TR_LINEAR;
|
||||
lent->e->s.apos.trDelta[0] = vec[0];
|
||||
lent->e->s.apos.trDelta[1] = vec[1];
|
||||
lent->e->s.apos.trDelta[2] = vec[2];
|
||||
|
||||
lua_pushboolean(L, qtrue);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -475,14 +573,19 @@ static int Entity_GC(lua_State * L)
|
|||
// Prints an entity as string
|
||||
static int Entity_ToString(lua_State * L)
|
||||
{
|
||||
lent_t *lent;
|
||||
gentity_t *gent;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
lent_t* lent = NULL;
|
||||
gentity_t* gent = NULL;
|
||||
char buf[MAX_STRING_CHARS];
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
gent = lent->e;
|
||||
Com_sprintf(buf, sizeof(buf), "entity: class=%s name=%s id=%i pointer=%p\n", gent->classname, gent->targetname, gent - g_entities,
|
||||
gent);
|
||||
Com_sprintf(buf, sizeof(buf), "entity: class=%s name=%s id=%i pointer=%p\n", gent->classname, gent->targetname, gent-g_entities, gent);
|
||||
lua_pushstring(L, buf);
|
||||
|
||||
return 1;
|
||||
|
@ -497,46 +600,57 @@ static void ent_delay(gentity_t *ent) {
|
|||
// entity.DelayedCallSpawn(entity ent, integer delay)
|
||||
// Calls the game logic spawn function for the class of ent after a delay of delay milliseconds.
|
||||
static int Entity_DelayedCallSpawn(lua_State *L) {
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
int delay;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || !lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Q_stricmp(lent->e->classname, "target_selfdestruct"))
|
||||
if(!Q_stricmp(lent->e->classname, "target_selfdestruct")) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1; //we will not selfdestruct this way
|
||||
}
|
||||
|
||||
delay = luaL_checkint(L, 2);
|
||||
|
||||
if(!delay)
|
||||
if(!delay) {
|
||||
delay = FRAMETIME;
|
||||
}
|
||||
|
||||
lent->e->nextthink = delay;
|
||||
lent->e->think = ent_delay;
|
||||
|
||||
lua_pushboolean(L, qtrue);
|
||||
return 1;
|
||||
}
|
||||
|
||||
// entity.CallSpawn(entity ent)
|
||||
// Calls the game logic spawn function for the class of ent.
|
||||
static int Entity_CallSpawn(lua_State *L) {
|
||||
lent_t *lent;
|
||||
lent_t* lent = NULL;
|
||||
qboolean r = qfalse;
|
||||
gentity_t *e = NULL;
|
||||
gentity_t* e = NULL;
|
||||
|
||||
LUA_DEBUG("Entity_CallSpawn - start");
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(lent)
|
||||
if(lent != NULL) {
|
||||
e = lent->e;
|
||||
} else {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(!Q_stricmp(lent->e->classname, "target_selfdestruct"))
|
||||
if(!Q_stricmp(lent->e->classname, "target_selfdestruct")) {
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1; //we will not selfdestruct this way
|
||||
}
|
||||
|
||||
if(e) {
|
||||
if(e != NULL) {
|
||||
LUA_DEBUG("Entity_CallSpawn - G_CallSpawn");
|
||||
trap_UnlinkEntity(e);
|
||||
r = G_CallSpawn(e);
|
||||
|
@ -546,7 +660,7 @@ static int Entity_CallSpawn(lua_State *L) {
|
|||
LUA_DEBUG("Entity_CallSpawn - NULL entity");
|
||||
}
|
||||
|
||||
lua_pushboolean(L, 0);
|
||||
lua_pushboolean(L, qfalse);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -766,7 +880,10 @@ static int Entity_IsLocked(lua_State *L) {
|
|||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
|
||||
if(!lent || lent->e) return 1;
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
lua_pushnil(L);
|
||||
return 1;
|
||||
}
|
||||
|
||||
ent = lent->e;
|
||||
|
||||
|
@ -1176,8 +1293,9 @@ static int Entity_SetEnemy(lua_State *L) {
|
|||
lent_t *enemy;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || lent->e)
|
||||
if(lent == NULL || lent->e == NULL) {
|
||||
return 1;
|
||||
}
|
||||
if(lua_isnil(L, 2)) {
|
||||
lent->e->enemy = NULL;
|
||||
} else {
|
||||
|
@ -1782,7 +1900,7 @@ static int Entity_GetModel(lua_State *L) {
|
|||
lent_t *lent;
|
||||
|
||||
lent = Lua_GetEntity(L, 1);
|
||||
if(!lent || lent->e)
|
||||
if(lent == NULL || lent->e == NULL)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
lua_pushstring(L, lent->e->model);
|
||||
|
|
|
@ -110,7 +110,7 @@ static int Mover_AsTrain(lua_State * L)
|
|||
if(!targ) return 1;
|
||||
} else {
|
||||
tlent = Lua_GetEntity(L, 2);
|
||||
if(!tlent || tlent->e) return 1;
|
||||
if(!tlent || tlent->e == NULL) return 1;
|
||||
targ = tlent->e;
|
||||
}
|
||||
|
||||
|
|
|
@ -918,6 +918,10 @@ char *Q_CleanStr( char *string ) {
|
|||
char* s;
|
||||
int c;
|
||||
|
||||
if(string == NULL) {
|
||||
return string;
|
||||
}
|
||||
|
||||
s = string;
|
||||
d = string;
|
||||
while ((c = *s) != 0 ) {
|
||||
|
@ -1162,8 +1166,8 @@ Info_RemoveKey_Big
|
|||
*/
|
||||
void Info_RemoveKey_Big( char *s, const char *key ) {
|
||||
char *start;
|
||||
char pkey[BIG_INFO_KEY];
|
||||
char value[BIG_INFO_VALUE];
|
||||
char pkey[BIG_INFO_KEY]; // TODO move to heap?
|
||||
char value[BIG_INFO_VALUE]; // TODO move to heap?
|
||||
char *o;
|
||||
|
||||
if ( strlen( s ) >= BIG_INFO_STRING ) {
|
||||
|
|
Loading…
Reference in a new issue