30 Nov 2008

This commit is contained in:
g-cont 2008-11-30 00:00:00 +03:00 committed by Alibek Omarov
parent 4fcae8e75f
commit 1357ca059c
26 changed files with 5180 additions and 4869 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -477,7 +477,7 @@ void UnparseEntities( void )
char *buf, *end;
char line[2048];
char key[MAX_KEY], value[MAX_VALUE];
const char *value2;
char *value2;
int i;
buf = dentdata;
@ -491,14 +491,20 @@ void UnparseEntities( void )
// certain entities get stripped from bsp file */
value2 = ValueForKey( &entities[i], "classname" );
if(!com.stricmp( value2, "_decal" ) || !com.stricmp( value2, "_skybox" ))
continue;
com.strcat( end, "{\n" );
end += 2;
// always place "classname" at first
StripTrailing( value2 );
com.snprintf( line, 2048, "\"classname\" \"%s\"\n", value2 );
com.strcat( end, line );
end += com.strlen( line );
for( ep = entities[i].epairs; ep; ep = ep->next )
{
if( !com.stricmp( ep->key, "classname" ))
continue; // already stored
com.strncpy( key, ep->key, MAX_KEY );
StripTrailing( key );
com.strncpy( value, ep->value, MAX_VALUE );

View File

@ -81,7 +81,7 @@ bool CL_ParseUserMessage( int svc_number )
// setup args
PRVM_G_FLOAT(OFS_PARM0) = (float)svc_number;
PRVM_ExecuteProgram (prog->globals.cl->HUD_ParseMessage, "HUD_ParseMessage");
msg_parsed = PRVM_G_FLOAT(OFS_RETURN);
msg_parsed = (bool)PRVM_G_FLOAT(OFS_RETURN);
return msg_parsed;
}
@ -638,9 +638,9 @@ VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
VM_atof, // #35 float atof( string s )
VM_atoi, // #36 float atoi( string s )
VM_atov, // #37 vector atov( string s )
NULL, // #38 -- reserved --
NULL, // #39 -- reserved --
NULL, // #40 -- reserved --

View File

@ -251,6 +251,9 @@ void VM_CvarGetString( void );
void VM_AddCommand( void );
void VM_Random( void );
void VM_ComVA( void );
void VM_atof( void );
void VM_atoi( void );
void VM_atov( void );
void VM_ComStrlen( void );
void VM_TimeStamp( void );
void VM_SubString( void );

View File

@ -703,6 +703,45 @@ void VM_ComVA( void )
}
/*
=========
VM_atof
float atof( string s )
=========
*/
void VM_atof( void )
{
if(!VM_ValidateArgs( "atof", 1 )) return;
PRVM_G_FLOAT(OFS_RETURN) = com.atof(PRVM_G_STRING(OFS_PARM0));
}
/*
=========
VM_atoi
float atoi( string s )
=========
*/
void VM_atoi( void )
{
if(!VM_ValidateArgs( "atoi", 1 )) return;
PRVM_G_FLOAT(OFS_RETURN) = com.atoi(PRVM_G_STRING(OFS_PARM0));
}
/*
=========
VM_atof
vector atov( string s )
=========
*/
void VM_atov( void )
{
if(!VM_ValidateArgs( "atov", 1 )) return;
com.atov( PRVM_G_VECTOR(OFS_RETURN), PRVM_G_STRING(OFS_PARM0), 3 );
}
/*
=========
VM_ComStrlen
@ -845,7 +884,7 @@ void VM_NextEdict( void )
edict_t *ent;
int i;
if(!VM_ValidateArgs( "nextent", 1 ))
if( !VM_ValidateArgs( "nextent", 1 ))
return;
i = PRVM_G_EDICTNUM( OFS_PARM0 );
@ -858,8 +897,8 @@ void VM_NextEdict( void )
VM_RETURN_EDICT( prog->edicts );
return;
}
ent = PRVM_EDICT_NUM(i);
if(!ent->priv.ed->free)
ent = PRVM_EDICT_NUM( i );
if( !ent->priv.ed->free )
{
VM_RETURN_EDICT( ent );
return;
@ -1590,9 +1629,9 @@ VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
VM_atof, // #35 float atof( string s )
VM_atoi, // #36 float atoi( string s )
VM_atov, // #37 vector atov( string s )
NULL, // #38 -- reserved --
NULL, // #39 -- reserved --
NULL, // #40 -- reserved --

View File

@ -699,9 +699,9 @@ VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
VM_atof, // #35 float atof( string s )
VM_atoi, // #36 float atoi( string s )
VM_atov, // #37 vector atov( string s )
NULL, // #38 -- reserved --
NULL, // #39 -- reserved --
NULL, // #40 -- reserved --

View File

@ -42,9 +42,10 @@ struct sv_globalvars_s
func_t PlayerPreThink;
func_t PlayerPostThink;
func_t ClientConnect;
func_t ClientCommand;
func_t ClientDisconnect;
func_t PutClientInServer;
func_t ClientCommand;
func_t KeyValue;
func_t ClientUserInfoChanged;
func_t EmitSound;
};
@ -152,6 +153,6 @@ struct sv_entvars_s
float team;
};
#define PROG_CRC_SERVER 1737
#define PROG_CRC_SERVER 8505
#endif//SV_EDICT_H

View File

@ -81,6 +81,15 @@ void SV_UpdateEntityState( edict_t *ent )
ent->priv.sv->s.model.controller[i] = ent->progs.sv->controller[i];
}
if( ent->priv.sv->s.ed_type != ED_VIEWMODEL )
ent->priv.sv->s.movetype = ent->progs.sv->movetype;
if( ent->priv.sv->s.ed_type == ED_MOVER || ent->priv.sv->s.ed_type == ED_BSPBRUSH )
{
// these needs to right calculate direction of scroll texture
VectorCopy( ent->progs.sv->movedir, ent->priv.sv->s.velocity );
}
if( ent->priv.sv->s.ed_type == ED_VIEWMODEL )
{
// copy v_model state from client to viemodel entity
@ -101,11 +110,11 @@ void SV_UpdateEntityState( edict_t *ent )
if( ent->progs.sv->fixangle )
{
// FIXME: set angles
//for( i = 0; i < 3; i++ )
// ent->priv.sv->s.delta_angles[i] = ANGLE2SHORT( ent->priv.sv->s.angles[i] );
//VectorClear( ent->priv.sv->s.angles );
//VectorClear( ent->priv.sv->s.viewangles );
//VectorClear( ent->progs.sv->v_angle );
for( i = 0; i < 3; i++ )
ent->priv.sv->s.delta_angles[i] = ANGLE2SHORT( ent->priv.sv->s.angles[i] );
VectorClear( ent->priv.sv->s.angles );
VectorClear( ent->priv.sv->s.viewangles );
VectorClear( ent->progs.sv->v_angle );
// and clear fixangle for the next frame
ent->progs.sv->fixangle = 0;
@ -256,6 +265,10 @@ static void SV_AddEntitiesToPacket( vec3_t origin, client_frame_t *frame, sv_ent
ent = PRVM_EDICT_NUM( e );
force = false; // clear forceflag
// completely ignore dormant entity
if((int)ent->progs.sv->flags & FL_DORMANT )
continue;
// send viewmodel entity always
// NOTE: never apply LinkEdict to viewmodel entity, because
// we wan't see it in list of entities returned with SV_AreaEdicts

View File

@ -1507,7 +1507,7 @@ void SV_Physics_Conveyor( edict_t *ent )
{
if( tr.plane.normal[2] > 0 )
{
v[2] = ent->progs.sv->speed * sqrt(1.0 - tr.plane.normal[2]*tr.plane.normal[2]) / tr.plane.normal[2];
v[2] = ent->progs.sv->speed * com.sqrt( 1.0 - tr.plane.normal[2]*tr.plane.normal[2]) / tr.plane.normal[2];
if(DotProduct( ent->progs.sv->movedir, tr.plane.normal) > 0)
v[2] = -v[2]; // then we're moving down
move[2] = v[2] * 0.1f;

View File

@ -675,11 +675,12 @@ void SV_RestoreEdict( edict_t *ent )
ent->priv.sv->s.soundindex = SV_SoundIndex(PRVM_GetString(ent->progs.sv->loopsound));
}
bool SV_ParseKeyValue( edict_t *ent, const char *key, const char *value )
void SV_ParseKeyValue( edict_t *ent, const char *key, const char *value )
{
// FIXME: implement
Msg("ParseKeyValue: %s - %s\n", key, value );
return false;
prog->globals.sv->pev = PRVM_EDICT_TO_PROG( ent );
PRVM_G_INT(OFS_PARM0) = PRVM_SetEngineString( key );
PRVM_G_INT(OFS_PARM1) = PRVM_SetEngineString( value );
PRVM_ExecuteProgram (prog->globals.sv->KeyValue, "KeyValue" );
}
void SV_VM_Begin( void )
@ -2446,9 +2447,9 @@ VM_TimeStamp, // #31 string Com_TimeStamp( float format )
VM_LocalCmd, // #32 void LocalCmd( ... )
VM_SubString, // #33 string substring( string s, float start, float length )
VM_AddCommand, // #34 void Add_Command( string s )
NULL, // #35 -- reserved --
NULL, // #36 -- reserved --
NULL, // #37 -- reserved --
VM_atof, // #35 float atof( string s )
VM_atoi, // #36 float atoi( string s )
VM_atov, // #37 vector atov( string s )
NULL, // #38 -- reserved --
NULL, // #39 -- reserved --
NULL, // #40 -- reserved --

View File

@ -202,14 +202,14 @@ void SV_ClassifyEdict( edict_t *ent )
}
else if( ent->progs.sv->movetype == MOVETYPE_PHYSIC )
sv_ent->s.ed_type = ED_RIGIDBODY;
else if( ent->progs.sv->solid == SOLID_BSP )
else if( ent->progs.sv->solid == SOLID_BSP || VectorIsNull( ent->progs.sv->origin ))
{
if((int)ent->progs.sv->flags & FL_WORLDBRUSH )
if( ent->progs.sv->movetype == MOVETYPE_CONVEYOR )
sv_ent->s.ed_type = ED_MOVER;
else if((int)ent->progs.sv->flags & FL_WORLDBRUSH )
sv_ent->s.ed_type = ED_BSPBRUSH;
else if( ent->progs.sv->movetype == MOVETYPE_PUSH )
sv_ent->s.ed_type = ED_MOVER;
else if( ent->progs.sv->movetype == MOVETYPE_CONVEYOR )
sv_ent->s.ed_type = ED_MOVER;
else if( ent->progs.sv->movetype == MOVETYPE_NONE )
sv_ent->s.ed_type = ED_BSPBRUSH;
}

View File

@ -310,10 +310,10 @@ void com_atov( float *vec, const char *str, size_t siz )
for ( j = 0; j < siz; j++ )
{
vec[j] = com_atof( pfront );
vec[j] = com.atof( pfront );
// valid separator is space or ,
while( *pstr && (*pstr != ' ' || *pstr != ',' ))
// valid separator is space
while( *pstr && *pstr != ' ' )
pstr++;
if (!*pstr) break;

View File

@ -159,7 +159,7 @@ typedef struct prvm_prog_s
void (*count_edicts)(void);
bool (*load_edict)(edict_t *ent); // initialize edict for first loading
void (*restore_edict)(edict_t *ent); // restore edict from savegame or changelevel
bool (*keyvalue_edict)(edict_t *ent, const char *key, const char *value ); // KeyValueData
void (*keyvalue_edict)(edict_t *ent, const char *key, const char *value ); // KeyValueData
void (*init_cmd)(void);
void (*reset_cmd)(void);
void (*error_cmd)(const char *format, ...);

View File

@ -67,5 +67,5 @@ if exist vsound\vsound.plg del /f /q vsound\vsound.plg
echo Build succeeded!
echo Please wait. Xash is now loading
cd D:\Xash3D\
quake.exe -game tmpQuArK -dev 3 -log +map qctest
quake.exe -game tmpQuArK -dev 3 -log +map newmap
:done

View File

@ -1000,6 +1000,23 @@ static void RB_CalcTextureCoords( stageBundle_t *bundle, uint unit )
ref.texCoordArray[unit][j][1] += st[1];
}
break;
case TCMOD_CONVEYOR:
if( m_pCurrentEntity->framerate == 0.0f ) return;
now = (m_pCurrentEntity->framerate * m_fShaderTime) * 0.0039; // magic number :-)
s = m_pCurrentEntity->movedir[0];
t = m_pCurrentEntity->movedir[1];
st[0] = now * s;
st[0] -= floor(st[0]);
st[1] = now * t;
st[1] -= floor(st[1]);
for( j = 0; j < ref.numVertex; j++ )
{
ref.texCoordArray[unit][j][0] -= st[0];
ref.texCoordArray[unit][j][1] += st[1];
}
break;
case TCMOD_ROTATE:
rad = -DEG2RAD( tcMod->params[0] * m_fShaderTime );
s = com.sin( rad );

View File

@ -522,6 +522,7 @@ typedef struct ref_entity_s
vec3_t angles;
vec3_t origin; // position
vec3_t movedir; // forward vector that computed on a server
matrix3x3 matrix; // rotation vectors
float framerate; // custom framerate

View File

@ -1080,6 +1080,12 @@ static bool R_AddEntityToScene( entity_state_t *s1, entity_state_t *s2, float le
refent->renderfx = s1->renderfx;
refent->prev.sequencetime = s1->model.animtime - s2->model.animtime;
if( refent->ent_type == ED_MOVER || refent->ent_type == ED_BSPBRUSH )
{
// store conveyor movedir in pev->velocity
VectorNormalize2( s1->velocity, refent->movedir );
}
// calculate angles
if( refent->effects & EF_ROTATE )
{

View File

@ -3891,13 +3891,20 @@ static ref_shader_t *R_CreateDefaultShader( const char *name, int shaderType, ui
}
shader->stages[0]->bundles[0]->numTextures++;
// support for hl1 "scroll" textures
if( com.stristr( shader->stages[0]->bundles[0]->textures[0]->name, "SCROLL" ))
{
shader->stages[0]->flags |= STAGEBUNDLE_TCMOD;
shader->stages[0]->bundles[0]->tcMod[0].type = TCMOD_CONVEYOR;
shader->stages[0]->bundles[0]->tcModNum++;
}
// fast presets
if( shader->surfaceParm & SURF_BLEND )
{
shader->stages[0]->flags |= SHADERSTAGE_BLENDFUNC;
shader->stages[0]->blendFunc.src = GL_SRC_ALPHA;
shader->stages[0]->blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
shader->flags |= SHADER_ENTITYMERGABLE; // using renderamt
}
else if( shader->surfaceParm & SURF_ALPHA )
{
@ -3906,7 +3913,6 @@ static ref_shader_t *R_CreateDefaultShader( const char *name, int shaderType, ui
shader->stages[0]->blendFunc.dst = GL_ONE_MINUS_SRC_ALPHA;
shader->stages[0]->alphaFunc.func = GL_GREATER;
shader->stages[0]->alphaFunc.ref = 0.666;
shader->flags |= SHADER_ENTITYMERGABLE; // using renderamt
}
if( shader->surfaceParm & SURF_WARP )
{

View File

@ -206,7 +206,8 @@ typedef enum
TCMOD_ROTATE,
TCMOD_STRETCH,
TCMOD_TURB,
TCMOD_TRANSFORM
TCMOD_TRANSFORM,
TCMOD_CONVEYOR // same as TCMOD_SCROLL, but dynamically changed by entity
} tcModType_t;
typedef enum

View File

@ -368,15 +368,14 @@ keyword_t pr_keywords[] =
{KEYWORD_DEFAULT, "default", "", 0 },
{KEYWORD_GOTO, "goto", "", 0 },
{KEYWORD_INT, "int", "integer",0 },
{KEYWORD_STATE, "state", "", ev_field},
{KEYWORD_STATE, "state", "", ev_field},// intrinsic
{KEYWORD_CLASS, "class", "", 0 },
{KEYWORD_STRUCT, "struct", "", 0 },
{KEYWORD_SWITCH, "switch", "", 0 },
{KEYWORD_TYPEDEF, "typedef", "", 0 },
{KEYWORD_EXTERN, "extern", "", 0 },
{KEYWORD_VAR, "var", "", 0 }, // FIXME: get rid of this
{KEYWORD_UNION, "union", "", 0 },
{KEYWORD_THINKTIME, "thinktime", "", 0 },
{KEYWORD_THINKTIME, "thinktime", "", 0 }, // intrinsic
{KEYWORD_BOOL, "bool", "BOOL", 0 },
{KEYWORD_ASM, "asm", "_asm", 0 },
{KEYWORD_SHARED, "shared", "_export",0 }, // rename to ?
@ -543,7 +542,6 @@ char *PR_NameFromType( etype_t type )
case ev_vector: com.strncpy(typeinfo, "vector", 32 ); break;
case ev_entity: com.strncpy(typeinfo, "entity", 32 ); break;
case ev_integer: com.strncpy(typeinfo, "int", 32 ); break;
case ev_variant: com.strncpy(typeinfo, "var", 32 ); break;
case ev_struct: com.strncpy(typeinfo, "struct", 32 ); break;
case ev_union: com.strncpy(typeinfo, "union", 32 ); break;
case ev_void: com.strncpy(typeinfo, "void", 32 ); break;
@ -564,7 +562,6 @@ void PR_KeyWordValid( char *name, type_t *type )
case ev_vector:
case ev_entity:
case ev_integer:
case ev_variant:
case ev_struct:
case ev_union:
typeinfo = PR_NameFromType( type->type );
@ -580,8 +577,8 @@ void PR_KeyWordValid( char *name, type_t *type )
if(!STRCMP(name, pr_keywords[i].name))
{
// MSVC 6.0 style
PR_ParseWarning(ERR_ILLEGALNAME, "'%s' followed by '%s' is illegal", typeinfo, name );
PR_ParseWarning(WARN_IGNOREDONLEFT, "' ' : ignored on left of '%s ' when no variable is declared", typeinfo );
PR_ParseWarning( ERR_ILLEGALNAME, "'%s' followed by '%s' is illegal", typeinfo, name );
PR_ParseWarning( WARN_IGNOREDONLEFT, "' ' : ignored on left of '%s ' when no variable is declared", typeinfo );
break;
}
}
@ -592,18 +589,18 @@ void PR_GetEntvarsName( void )
def_t *d;
// for emit class constructor we need before
// get name of global entvars pointer (default "self")
// get name of global entvars pointer (default "pev")
if(pr_setevarsname) return;
if( pr_setevarsname ) return;
for (d = pr.def_head.next; d; d = d->next)
for( d = pr.def_head.next; d; d = d->next )
{
if (!com.strcmp (d->name, "end_sys_globals")) break;
if (d->ofs < RESERVED_OFS) continue;
if (d->type->type == ev_entity)
if( !com.strcmp (d->name, "end_sys_globals" )) break;
if( d->ofs < RESERVED_OFS ) continue;
if( d->type->type == ev_entity )
{
com.strncpy(pevname, d->name, 32 );
com.strncpy(opevname, va("o%s", pevname), 32 );
com.strncpy( pevname, d->name, 32 );
com.strncpy( opevname, va( "o%s", pevname ), 32 );
pr_setevarsname = true;
break;
}
@ -1434,59 +1431,59 @@ def_t *PR_ParseFunctionCall (def_t *func)
func->timescalled++;
t = func->type;
if(t && t->type == ev_variant) t->aux_type = type_variant;
if(t && t->type != ev_function && t->type != ev_variant)
if( t && t->type != ev_function )
{
PR_ParseErrorPrintDef (ERR_NOTAFUNCTION, func, "not a function");
PR_ParseErrorPrintDef( ERR_NOTAFUNCTION, func, "not a function" );
}
if (!t->num_parms && t->type != ev_variant)
if( !t->num_parms )
{
// intrinsics. These base functions have variable arguments. I would check for (...) args too,
// but that might be used for extended builtin functionality. (this code wouldn't compile otherwise)
if (!com.strcmp(func->name, "spawn"))
if( !com.strcmp( func->name, "spawn" ))
{
type_t *rettype;
if (PR_CheckToken(")"))
if( PR_CheckToken( ")" ))
{
rettype = type_entity;
}
else
{
rettype = TypeForName(PR_ParseName());
if (!rettype || rettype->type != ev_entity)
PR_ParseError(ERR_NOTANAME, "Spawn operator with undefined class");
rettype = TypeForName( PR_ParseName());
if( !rettype || rettype->type != ev_entity )
PR_ParseError(ERR_NOTANAME, "spawn operator with undefined class" );
PR_Expect(")");
}
if (def_ret.temp->used)
PR_ParseWarning(0, "Return value conflict - output is likly to be invalid");
if( def_ret.temp->used )
PR_ParseWarning( 0, "return value conflict - output is likly to be invalid" );
def_ret.temp->used = true;
if (rettype != type_entity)
if( rettype != type_entity )
{
char genfunc[2048];
com.sprintf(genfunc, "Class*%s", rettype->name);
func = PR_GetDef(type_function, genfunc, NULL, true, 1);
char genfunc[2048];
com.sprintf( genfunc, "Class*%s", rettype->name );
func = PR_GetDef( type_function, genfunc, NULL, true, 1 );
func->references++;
}
PR_SimpleStatement(OP_CALL0, func->ofs, 0, 0, false);
PR_SimpleStatement( OP_CALL0, func->ofs, 0, 0, false );
def_ret.type = rettype;
return &def_ret;
}
else if (!com.strcmp(func->name, "entnum") && !PR_CheckToken(")"))
else if( !com.strcmp( func->name, "entnum" ) && !PR_CheckToken( ")" ))
{
// t = (a/%1) / (nextent(world)/%1)
// a/%1 does a (int)entity to float conversion type thing
e = PR_Expression(TOP_PRIORITY, false);
PR_Expect(")");
e = PR_Statement(&pr_opcodes[OP_DIV_F], e, PR_MakeIntDef(1), (dstatement_t **)0xffffffff);
e = PR_Statement(&pr_opcodes[OP_DIV_F], e, PR_MakeIntDef( 1 ), (dstatement_t **)0xffffffff);
d = PR_GetDef(NULL, "nextent", NULL, false, 0);
if (!d) PR_ParseError(0, "the nextent builtin is not defined");
PR_FreeTemp(PR_Statement(&pr_opcodes[OP_STORE_F], e, &def_parms[0], (dstatement_t **)0xffffffff));
d = PR_GetDef( NULL, "nextent", NULL, false, 0 );
if( !d ) PR_ParseError(0, "the nextent builtin is not defined");
PR_FreeTemp( PR_Statement(&pr_opcodes[OP_STORE_F], e, &def_parms[0], (dstatement_t **)0xffffffff));
d = PR_Statement(&pr_opcodes[OP_CALL0], d, NULL, NULL);
d = PR_Statement(&pr_opcodes[OP_DIV_F], d, PR_MakeIntDef(1), (dstatement_t **)0xffffffff);
@ -1496,30 +1493,25 @@ def_t *PR_ParseFunctionCall (def_t *func)
}
} // so it's not an intrinsic.
if (opt_precache_file)
if( opt_precache_file )
{
// should we strip out all precache_file calls?
if (!com.strncmp(func->name,"precache_file", 13))
if( !com.strncmp( func->name,"precache_file", 13 ))
{
if (pr_token_type == tt_immediate && pr_immediate_type->type == ev_string)
if( pr_token_type == tt_immediate && pr_immediate_type->type == ev_string )
{
PR_Lex();
PR_Expect(")");
PR_Expect( ")" );
def_ret.type = type_void;
return &def_ret;
}
}
}
PR_LockActiveTemps(); // any temps before are likly to be used with the return value.
PR_LockActiveTemps(); // any temps before are likely to be used with the return value.
// any temps referenced to build the parameters don't need to be locked.
// copy the arguments to the global parameter variables
if (t->type == ev_variant)
{
extraparms = true;
np = 0;
}
else if (t->num_parms < 0)
if( t->num_parms < 0 )
{
extraparms = true;
np = (t->num_parms * -1) - 1;
@ -1665,7 +1657,7 @@ def_t *PR_ParseFunctionCall (def_t *func)
// you're allowed to use int 0 to pass a null function pointer
// this is basically because __NULL__ is defined as ~0 (int 0)
}
else if (p->type != ev_variant)
else
{
// can cast to variant whatever happens
if (opt_laxcasts || (p->type == ev_function && e->type->type == ev_function))
@ -1751,36 +1743,31 @@ def_t *PR_ParseFunctionCall (def_t *func)
else PR_FreeTemp(PR_Statement (&pr_opcodes[OP_CALL0], func, 0, (dstatement_t **)&st));
if (opev) PR_SimpleStatement(OP_STORE_ENT, opev->ofs, d->ofs, 0, false);
for(; arg; arg--)
for( ; arg; arg-- )
{
PR_FreeTemp(param[arg-1]);
PR_FreeTemp( param[arg-1] );
}
if (old)
if( old )
{
if (t->type == ev_variant)
{
d = PR_GetTemp(type_variant);
PR_FreeTemp(PR_Statement(pr_opcodes+OP_STORE_F, &def_ret, d, NULL));
}
else
{
d = PR_GetTemp(t->aux_type);
if (t->aux_type->size == 3) PR_FreeTemp(PR_Statement(pr_opcodes+OP_STORE_V, &def_ret, d, NULL));
else PR_FreeTemp(PR_Statement(pr_opcodes+OP_STORE_F, &def_ret, d, NULL));
}
if (def_ret.type->size == 3) PR_FreeTemp(PR_Statement(pr_opcodes+OP_STORE_V, old, &def_ret, NULL));
else PR_FreeTemp(PR_Statement(pr_opcodes+OP_STORE_F, old, &def_ret, NULL));
PR_FreeTemp(old);
PR_UnFreeTemp(&def_ret);
PR_UnFreeTemp(d);
d = PR_GetTemp(t->aux_type);
if( t->aux_type->size == 3 ) PR_FreeTemp( PR_Statement( pr_opcodes+OP_STORE_V, &def_ret, d, NULL ));
else PR_FreeTemp( PR_Statement( pr_opcodes+OP_STORE_F, &def_ret, d, NULL ));
if( def_ret.type->size == 3 ) PR_FreeTemp( PR_Statement(pr_opcodes+OP_STORE_V, old, &def_ret, NULL ));
else PR_FreeTemp(PR_Statement( pr_opcodes+OP_STORE_F, old, &def_ret, NULL ));
PR_FreeTemp( old );
PR_UnFreeTemp( &def_ret );
PR_UnFreeTemp( d );
return d;
}
if (t->type == ev_variant) def_ret.type = type_variant;
else def_ret.type = t->aux_type;
if (def_ret.temp->used) PR_ParseWarning(WARN_FIXEDRETURNVALUECONFLICT, "Return value conflict - output is inefficient");
def_ret.type = t->aux_type;
if( def_ret.temp->used )
PR_ParseWarning( WARN_FIXEDRETURNVALUECONFLICT, "return value conflict - output is inefficient" );
def_ret.temp->used = true;
return &def_ret;
@ -2156,32 +2143,29 @@ def_t *PR_ParseValue (type_t *assumeclass)
if (!d)
{
// intrinsics, any old function with no args will do.
if ((!com.strcmp(name, "spawn")) || (!com.strcmp(name, "entnum")))
od = d = PR_GetDef (type_function, name, NULL, true, 1);
else if (PR_KeywordEnabled(KEYWORD_CLASS) && !com.strcmp(name, "this"))
if(( !com.strcmp( name, "spawn" )) || (!com.strcmp( name, "entnum" )))
od = d = PR_GetDef( type_function, name, NULL, true, 1 );
else if( PR_KeywordEnabled( KEYWORD_CLASS ) && !com.strcmp( name, "this" ))
{
if (!pr_classtype) PR_ParseError(ERR_NOTANAME, "Cannot use 'this' outside of an OO function\n");
od = PR_GetDef(NULL, pevname, NULL, true, 1);
od = d = PR_DummyDef(pr_classtype, "this", pr_scope, 1, od->ofs, true);
if( !pr_classtype )
PR_ParseError( ERR_NOTANAME, "cannot use 'this' outside of an OO function\n" );
od = PR_GetDef( NULL, pevname, NULL, true, 1 );
od = d = PR_DummyDef( pr_classtype, "this", pr_scope, 1, od->ofs, true );
}
else if (PR_KeywordEnabled(KEYWORD_CLASS) && !com.strcmp(name, "super"))
else if( PR_KeywordEnabled( KEYWORD_CLASS ) && !com.strcmp( name, "super" ))
{
if (!pr_classtype) PR_ParseError(ERR_NOTANAME, "Cannot use 'super' outside of an OO function\n");
od = PR_GetDef(NULL, pevname, NULL, true, 1);
od = d = PR_DummyDef(pr_classtype, "super", pr_scope, 1, od->ofs, true);
}
else
{
od = d = PR_GetDef (type_variant, name, pr_scope, true, 1);
if (!d) PR_ParseError (ERR_UNKNOWNVALUE, "Unknown value \"%s\"", name);
else PR_ParseWarning (ERR_UNKNOWNVALUE, "Unknown value \"%s\".", name);
if( !pr_classtype )
PR_ParseError( ERR_NOTANAME, "cannot use 'super' outside of an OO function\n" );
od = PR_GetDef( NULL, pevname, NULL, true, 1 );
od = d = PR_DummyDef( pr_classtype, "super", pr_scope, 1, od->ofs, true );
}
else PR_ParseError( ERR_UNKNOWNVALUE, "unknown value \"%s\"", name );
}
reloop:
// FIXME: Make this work with double arrays/2nd level structures.
// Should they just jump back to here?
if (PR_CheckToken("["))
if( PR_CheckToken( "[" ))
{
type_t *newtype;
if (ao)
@ -3240,44 +3224,47 @@ PR_ParseStatement
============
*/
void PR_ParseStatement (void)
void PR_ParseStatement( void )
{
int continues;
int breaks;
int cases;
int i;
int cases, i;
def_t *e, *e2;
dstatement_t *patch1, *patch2, *patch3;
int statementstart = pr_source_line;
if (PR_CheckToken ("{"))
if( PR_CheckToken( "{" ))
{
e = pr.localvars;
while (!PR_CheckToken("}")) PR_ParseStatement ();
while( !PR_CheckToken( "}" )) PR_ParseStatement();
if (pr_subscopedlocals)
if( pr_subscopedlocals )
{
for (e2 = pr.localvars; e2 != e; e2 = e2->nextlocal)
for( e2 = pr.localvars; e2 != e; e2 = e2->nextlocal )
{
Hash_RemoveData(&localstable, e2->name, e2);
Hash_RemoveData( &localstable, e2->name, e2 );
}
}
return;
}
if (PR_CheckForKeyword( KEYWORD_RETURN ))
if( PR_CheckForKeyword( KEYWORD_RETURN ))
{
if (PR_CheckToken (";"))
if( PR_CheckToken( ";" ))
{
if (pr_scope->type->aux_type->type != ev_void)
PR_ParseWarning(WARN_MISSINGRETURNVALUE, "\'%s\' should return %s", pr_scope->name, pr_scope->type->aux_type->name);
if (opt_return_only) PR_FreeTemp(PR_Statement (&pr_opcodes[OP_DONE], 0, 0, NULL));
if( pr_scope->type->aux_type->type != ev_void )
PR_ParseWarning( WARN_MISSINGRETURNVALUE, "\'%s\' should return %s", pr_scope->name, pr_scope->type->aux_type->name);
if( opt_return_only ) PR_FreeTemp(PR_Statement (&pr_opcodes[OP_DONE], 0, 0, NULL));
else PR_FreeTemp(PR_Statement (&pr_opcodes[OP_RETURN], 0, 0, NULL));
return;
}
e = PR_Expression (TOP_PRIORITY, true);
PR_Expect (";");
if (pr_scope->type->aux_type->type != e->type->type)
PR_ParseWarning(WARN_WRONGRETURNTYPE, "\'%s\' returned %s, expected %s", pr_scope->name, e->type->name, pr_scope->type->aux_type->name);
e = PR_Expression( TOP_PRIORITY, true );
PR_Expect( ";" );
if( pr_scope->type->aux_type->type != e->type->type )
{
if( pr_scope->type->aux_type->type == ev_void )
PR_ParseWarning( WARN_WRONGRETURNTYPE, "\'%s\' : 'void' function returning a value", pr_scope->name );
else PR_ParseWarning( WARN_WRONGRETURNTYPE, "\'%s\' returned %s, expected %s", pr_scope->name, e->type->name, pr_scope->type->aux_type->name);
}
PR_FreeTemp(PR_Statement (&pr_opcodes[OP_RETURN], e, 0, NULL));
return;
}
@ -3492,24 +3479,23 @@ void PR_ParseStatement (void)
{
bool result = false;
if (PR_MatchKeyword(KEYWORD_VAR)) result = true;
else if (PR_MatchKeyword(KEYWORD_STRING)) result = true;
else if (PR_MatchKeyword(KEYWORD_FLOAT)) result = true;
else if (PR_MatchKeyword(KEYWORD_ENTITY)) result = true;
else if (PR_MatchKeyword(KEYWORD_VECTOR)) result = true;
else if (PR_MatchKeyword(KEYWORD_INT)) result = true;
else if (PR_MatchKeyword(KEYWORD_CLASS)) result = true;
else if (PR_MatchKeyword(KEYWORD_CONST)) result = true;
if( PR_MatchKeyword( KEYWORD_STRING )) result = true;
else if( PR_MatchKeyword( KEYWORD_FLOAT )) result = true;
else if( PR_MatchKeyword( KEYWORD_ENTITY )) result = true;
else if( PR_MatchKeyword( KEYWORD_VECTOR )) result = true;
else if( PR_MatchKeyword( KEYWORD_INT )) result = true;
else if( PR_MatchKeyword( KEYWORD_CLASS )) result = true;
else if( PR_MatchKeyword( KEYWORD_CONST )) result = true;
else result = false;
if(result)
if( result )
{
PR_ParseDefs (NULL);
PR_ParseDefs( NULL );
locals_end = numpr_globals;
return;
}
}
if (PR_CheckForKeyword( KEYWORD_STATE ))
if( PR_CheckForKeyword( KEYWORD_STATE ))
{
PR_Expect("[");
PR_ParseState();
@ -4927,13 +4913,12 @@ def_t *PR_DummyDef(type_t *type, char *name, def_t *scope, int arraysize, uint o
case ev_integer:
case ev_struct:
case ev_union:
case ev_variant: // for lack of any better alternative
com.sprintf(newname, "%s%s.%s", name, array, parttype->name);
PR_DummyDef(parttype, newname, scope, 1, ofs + type->size*a + parttype->ofs, false);
com.sprintf( newname, "%s%s.%s", name, array, parttype->name );
PR_DummyDef( parttype, newname, scope, 1, ofs + type->size*a + parttype->ofs, false );
break;
case ev_function:
com.sprintf(newname, "%s%s.%s", name, array, parttype->name);
PR_DummyDef(parttype, newname, scope, 1, ofs + type->size*a +parttype->ofs, false)->initialized = true;
com.sprintf( newname, "%s%s.%s", name, array, parttype->name );
PR_DummyDef( parttype, newname, scope, 1, ofs + type->size*a +parttype->ofs, false)->initialized = true;
break;
case ev_void:
break;
@ -4941,7 +4926,7 @@ def_t *PR_DummyDef(type_t *type, char *name, def_t *scope, int arraysize, uint o
parttype = parttype->next;
}
}
else if (type->type == ev_vector)
else if( type->type == ev_vector )
{
// do the vector thing.
com.sprintf(newname, "%s%s_x", name, array);
@ -5207,19 +5192,18 @@ def_t *PR_DummyFieldDef(type_t *type, char *name, def_t *scope, int arraysize, u
case ev_field:
case ev_pointer:
case ev_integer:
case ev_variant:
if (*name) com.sprintf(newname, "%s%s.%s", name, array, parttype->name);
else com.sprintf(newname, "%s%s", parttype->name, array);
ftype = PR_NewType("FIELD TYPE", ev_field);
if( *name ) com.sprintf( newname, "%s%s.%s", name, array, parttype->name );
else com.sprintf( newname, "%s%s", parttype->name, array );
ftype = PR_NewType( "FIELD TYPE", ev_field );
ftype->aux_type = parttype;
// vector fields create a _y and _z too, so we need this still.
if (parttype->type == ev_vector) ftype->size = parttype->size;
def = PR_GetDef(NULL, newname, scope, false, 1);
if (!def) def = PR_GetDef(ftype, newname, scope, true, 1);
if( parttype->type == ev_vector ) ftype->size = parttype->size;
def = PR_GetDef( NULL, newname, scope, false, 1 );
if( !def ) def = PR_GetDef( ftype, newname, scope, true, 1 );
else
{
PR_ParseWarning(WARN_CONFLICTINGUNIONMEMBER, "conflicting offsets for union/struct expansion of %s. Ignoring new def.", newname);
PR_ParsePrintDef(WARN_CONFLICTINGUNIONMEMBER, def);
PR_ParseWarning( WARN_CONFLICTINGUNIONMEMBER, "conflicting offsets for union/struct expansion of %s. Ignoring new def.", newname );
PR_ParsePrintDef( WARN_CONFLICTINGUNIONMEMBER, def );
}
break;
case ev_function:
@ -5274,7 +5258,6 @@ void PR_ParseDefs (char *classname)
bool shared = false;
bool externfnc = false;
bool isconstant = false;
bool isvar = false;
bool nosave = false;
bool allocatenew = true;
int ispointer;
@ -5383,15 +5366,14 @@ void PR_ParseDefs (char *classname)
}
while(1)
{
if (PR_CheckForKeyword( KEYWORD_EXTERN )) externfnc = true;
else if (PR_CheckForKeyword( KEYWORD_SHARED ))
if( PR_CheckForKeyword( KEYWORD_EXTERN )) externfnc = true;
else if( PR_CheckForKeyword( KEYWORD_SHARED ))
{
shared = true;
if (pr_scope) PR_ParseError (ERR_NOSHAREDLOCALS, "Cannot have shared locals");
if( pr_scope ) PR_ParseError( ERR_NOSHAREDLOCALS, "cannot have shared locals" );
}
else if (PR_CheckForKeyword( KEYWORD_CONST )) isconstant = true;
else if (PR_CheckForKeyword( KEYWORD_VAR )) isvar = true;
else if (PR_CheckForKeyword( KEYWORD_NOSAVE )) nosave = true;
else if( PR_CheckForKeyword( KEYWORD_CONST )) isconstant = true;
else if( PR_CheckForKeyword( KEYWORD_NOSAVE )) nosave = true;
else break;
}
@ -5405,7 +5387,7 @@ void PR_ParseDefs (char *classname)
}
do
{
if (PR_CheckToken ("*"))
if( PR_CheckToken( "*" ))
{
ispointer = 1;
while(PR_CheckToken ("*")) ispointer++;
@ -5478,7 +5460,7 @@ void PR_ParseDefs (char *classname)
if (PR_CheckToken("(")) type = PR_ParseFunctionType(false, type);
if (classname)
if( classname )
{
char *membername = name;
name = Qalloc(com.strlen(classname) + com.strlen(name) + 3);
@ -5596,17 +5578,16 @@ void PR_ParseDefs (char *classname)
for (i = 0; i < d->type->size; i++) G_INT(def->ofs) = G_INT(d->ofs);
PR_Lex();
if (type->type == ev_function)
if( type->type == ev_function )
{
def->initialized = 1;
def->constant = !isvar;
def->constant = true;
}
continue;
}
else if (type->type == ev_function)
else if( type->type == ev_function )
{
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
if (PR_CheckToken("0"))
{
@ -5702,8 +5683,7 @@ void PR_ParseDefs (char *classname)
int arraypart, partnum;
type_t *parttype;
def->initialized = 1;
if (isvar) def->constant = true;
else def->constant = false;
def->constant = false;
// FIXME: should do this recursivly
PR_Expect("{");
@ -5807,11 +5787,9 @@ void PR_ParseDefs (char *classname)
PR_Expect("}");
continue;
}
else if (type->type == ev_integer)
else if( type->type == ev_integer )
{
// handle these differently, because they may need conversions
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
def->initialized = 1;
Mem_Copy (pr_globals + def->ofs, &pr_immediate, 4*type_size[pr_immediate_type->type]);
@ -5841,8 +5819,7 @@ void PR_ParseDefs (char *classname)
d->type = type_string;
d->name = "IMMEDIATE";
if (isvar) d->constant = false;
else d->constant = true;
d->constant = true;
d->initialized = 1;
d->scope = NULL;
@ -5858,8 +5835,7 @@ void PR_ParseDefs (char *classname)
}
else if (arraysize<=1)
{
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
def->initialized = 1;
(((int *)pr_globals)[def->ofs]) = PR_CopyString(pr_immediate_string, opt_noduplicatestrings );
PR_Lex();
@ -5889,8 +5865,7 @@ void PR_ParseDefs (char *classname)
}
else if (arraysize<=1)
{
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
def->initialized = 1;
if (pr_immediate_type->type != ev_float)
@ -5936,8 +5911,7 @@ void PR_ParseDefs (char *classname)
}
else if (arraysize<=1)
{
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
def->initialized = 1;
(((float *)pr_globals)[def->ofs+0]) = pr_immediate.vector[0];
(((float *)pr_globals)[def->ofs+1]) = pr_immediate.vector[1];
@ -5969,19 +5943,12 @@ void PR_ParseDefs (char *classname)
PR_ParseError (ERR_BADIMMEDIATETYPE, "wrong immediate type for %s - %s", name, pr_token);
else Mem_Copy (pr_globals + def->ofs, &pr_immediate, 4*type_size[pr_immediate_type->type]);
if (isvar) def->constant = false;
else def->constant = true;
def->constant = true;
def->initialized = true;
PR_Lex ();
}
else
{
if (type->type == ev_function && isvar)
{
isconstant = !isvar;
def->initialized = 1;
}
// special flag on fields, 2, makes the pointer obtained from them also constant.
if (isconstant && type->type == ev_field)
def->constant = 2;
@ -6188,7 +6155,6 @@ void PR_BeginCompilation ( void )
type_function = PR_NewType("function", ev_function);
type_pointer = PR_NewType("pointer", ev_pointer);
type_integer = PR_NewType("__integer", ev_integer);
type_variant = PR_NewType("__variant", ev_variant);
type_floatfield = PR_NewType("fieldfloat", ev_field);
type_pointer->aux_type = PR_NewType("pointeraux", ev_float);
if (PR_KeywordEnabled(KEYWORD_INT)) PR_NewType("int", ev_integer);

View File

@ -482,7 +482,6 @@ char *PRVM_UglyValueString (etype_t type, prvm_eval_t *val)
com.sprintf (line, "%i", val->_int);
break;
case ev_pointer:
case ev_variant:
case ev_struct:
case ev_union:
com.sprintf (line, "skip new type %i", type);
@ -691,7 +690,7 @@ void PRVM_ED_Read( int s_table, int entnum, dkeyvalue_t *fields, int numpairs )
key = PRVM_ED_FindField( keyname );
if( !key )
{
PRVM_GCALL(keyvalue_edict)(ent, keyname, value );
PRVM_GCALL(keyvalue_edict)( ent, keyname, value );
else MsgDev( D_WARN, "%s: unknown field '%s'\n", PRVM_NAME, keyname);
continue;
}
@ -1077,7 +1076,8 @@ const char *PRVM_ED_ParseEdict( const char *data, edict_t *ent )
key = PRVM_ED_FindField( keyname );
if( !key )
{
MsgDev(D_NOTE, "%s: unknown field '%s'\n", PRVM_NAME, keyname);
PRVM_GCALL(keyvalue_edict)( ent, keyname, pr_token );
else MsgDev( D_WARN, "%s: unknown field '%s'\n", PRVM_NAME, keyname);
continue;
}
@ -1090,7 +1090,7 @@ const char *PRVM_ED_ParseEdict( const char *data, edict_t *ent )
}
if(!PRVM_ED_ParseEpair( ent, key, pr_token )) PRVM_ERROR ("PRVM_ED_ParseEdict: parse error");
}
if(!init) ent->priv.ed->free = true;
if( !init ) ent->priv.ed->free = true;
return data;
}

View File

@ -1440,11 +1440,11 @@ chooseexecprogram:
{
vm.prog->xfunction->profile += (st - startst);
vm.prog->xstatement = st - vm.prog->statements;
PRVM_ERROR("OP_STATE not supported by %s", PRVM_NAME);
PRVM_ERROR("OP_THINKTIME not supported by %s", PRVM_NAME);
}
break;
case OP_MODULO_I:
OPC->_int = (OPA->_int % OPB->_int);
OPC->_int = (int)(OPA->_int % OPB->_int);
case OP_MODULO_F:
OPC->_float = fmod( OPA->_float, OPB->_float );
break;

View File

@ -120,7 +120,6 @@ enum
KEYWORD_SWITCH,
KEYWORD_TYPEDEF,
KEYWORD_EXTERN,
KEYWORD_VAR,
KEYWORD_UNION,
KEYWORD_THINKTIME,
@ -144,7 +143,6 @@ typedef enum
ev_function,
ev_pointer,
ev_integer,
ev_variant,
ev_struct,
ev_union,
ev_bool,
@ -509,7 +507,6 @@ extern type_t *type_field;
extern type_t *type_function;
extern type_t *type_pointer;
extern type_t *type_integer;
extern type_t *type_variant;
extern type_t *type_floatfield;
extern includechunk_t *currentchunk;
extern cachedsourcefile_t *sourcefile;

View File

@ -502,7 +502,7 @@ word PR_WriteProgdefs( void )
switch( crc )
{
case 1737:
case 8505:
PR_Message("Xash3D unmodified server.dat\n");
if(!com.strcmp(progsoutname, "unknown.dat")) com.strcpy(progsoutname, "server.dat");
break;