12 Nov 2007
This commit is contained in:
parent
24737fddb2
commit
02ad53214b
|
@ -54,7 +54,7 @@ scroll = visible_offset
|
|||
8. переписать вecь код рисования 2d (re->DrawPic)
|
||||
9. Добавить автоматическую систему levelshots OK
|
||||
10. новая система парсинга худ-программы
|
||||
11. консолька не всегда готова к приему комманд
|
||||
11. консолька не всегда готова к приему комманд OK
|
||||
12. Перенести наконец картинки в отдельную папку OK
|
||||
13. научить системную консоль убивать color prefixes OK
|
||||
14. переписать код загрузки уровня OK
|
||||
|
@ -63,10 +63,13 @@ scroll = visible_offset
|
|||
17. пофиксить дедикатед консольку OK
|
||||
18. пофиксить загрузку OK
|
||||
19. пофиксить вылет движка в release OK
|
||||
20. убрать мусор из консоли
|
||||
20. убрать мусор из консоли OK
|
||||
21. заменить все strcpy, strcat на strncpy, strncat
|
||||
22. исправить парсинг для studiomdl
|
||||
23. какие-то глюки отсечения визлифов (новый протокол глючит?)
|
||||
24. иконка не грузится для окошек OK
|
||||
25. Окончательно сформировать stdlib_api_t OK
|
||||
|
||||
|
||||
//==================================================
|
||||
// то, что уже готово
|
||||
|
|
|
@ -244,7 +244,7 @@ bspbrush_t *AllocBrush (int numsides)
|
|||
|
||||
c = (int)&(((bspbrush_t *)0)->sides[numsides]);
|
||||
bb = Malloc(c);
|
||||
if (numthreads == 1) c_active_brushes++;
|
||||
if (GetNumThreads() == 1) c_active_brushes++;
|
||||
return bb;
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ void FreeBrush (bspbrush_t *brushes)
|
|||
if (brushes->sides[i].winding)
|
||||
FreeWinding(brushes->sides[i].winding);
|
||||
Free (brushes);
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_active_brushes--;
|
||||
}
|
||||
|
||||
|
@ -783,7 +783,7 @@ side_t *SelectSplitSide (bspbrush_t *brushes, node_t *node)
|
|||
{
|
||||
if (pass > 1)
|
||||
{
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_nonvis++;
|
||||
}
|
||||
if (pass > 0)
|
||||
|
@ -1105,7 +1105,7 @@ node_t *BuildTree_r (node_t *node, bspbrush_t *brushes)
|
|||
int i;
|
||||
bspbrush_t *children[2];
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_nodes++;
|
||||
|
||||
// find the best plane to use as a splitter
|
||||
|
|
|
@ -495,11 +495,11 @@ epair_t *ParseEpair (void)
|
|||
|
||||
e = Malloc (sizeof(epair_t));
|
||||
|
||||
if (strlen(SC_Token()) >= MAX_KEY - 1) Sys_Error ("ParseEpar: token too long");
|
||||
e->key = copystring(SC_Token());
|
||||
SC_GetToken (false);
|
||||
if (strlen(SC_Token()) >= MAX_VALUE - 1) Sys_Error ("ParseEpar: token too long");
|
||||
e->value = copystring(SC_Token());
|
||||
if (strlen(com_token) >= MAX_KEY - 1) Sys_Error ("ParseEpar: token too long");
|
||||
e->key = copystring(com_token);
|
||||
Com_GetToken (false);
|
||||
if (strlen(com_token) >= MAX_VALUE - 1) Sys_Error ("ParseEpar: token too long");
|
||||
e->value = copystring(com_token);
|
||||
|
||||
// strip trailing spaces
|
||||
StripTrailing (e->key);
|
||||
|
@ -519,9 +519,9 @@ bool ParseEntity (void)
|
|||
epair_t *e;
|
||||
bsp_entity_t *mapent;
|
||||
|
||||
if (!SC_GetToken (true)) return false;
|
||||
if (!Com_GetToken (true)) return false;
|
||||
|
||||
if (!SC_MatchToken( "{") ) Sys_Error ("ParseEntity: { not found");
|
||||
if (!Com_MatchToken( "{") ) Sys_Error ("ParseEntity: { not found");
|
||||
if (num_entities == MAX_MAP_ENTITIES) Sys_Error ("num_entities == MAX_MAP_ENTITIES");
|
||||
|
||||
mapent = &entities[num_entities];
|
||||
|
@ -529,8 +529,8 @@ bool ParseEntity (void)
|
|||
|
||||
do
|
||||
{
|
||||
if (!SC_GetToken (true)) Sys_Error ("ParseEntity: EOF without closing brace");
|
||||
if (SC_MatchToken("}")) break;
|
||||
if (!Com_GetToken (true)) Sys_Error ("ParseEntity: EOF without closing brace");
|
||||
if (Com_MatchToken("}")) break;
|
||||
e = ParseEpair ();
|
||||
e->next = mapent->epairs;
|
||||
mapent->epairs = e;
|
||||
|
@ -549,7 +549,7 @@ Parses the dentdata string into entities
|
|||
void ParseEntities (void)
|
||||
{
|
||||
num_entities = 0;
|
||||
if(FS_LoadScript("entities", dentdata, entdatasize))
|
||||
if(Com_LoadScript("entities", dentdata, entdatasize))
|
||||
while(ParseEntity());
|
||||
}
|
||||
|
||||
|
|
|
@ -543,8 +543,8 @@ void ParseBrush (bsp_entity_t *mapent)
|
|||
do
|
||||
{
|
||||
g_TXcommand = 0;
|
||||
if (!SC_GetToken (true)) break;
|
||||
if (SC_MatchToken("}")) break;
|
||||
if (!Com_GetToken (true)) break;
|
||||
if (Com_MatchToken("}")) break;
|
||||
|
||||
if (nummapbrushsides == MAX_MAP_BRUSHSIDES)
|
||||
Sys_Error ("MAX_MAP_BRUSHSIDES");
|
||||
|
@ -553,76 +553,76 @@ void ParseBrush (bsp_entity_t *mapent)
|
|||
// read the three point plane definition
|
||||
for (i = 0; i < 3; i++)
|
||||
{
|
||||
if (i != 0) SC_GetToken (true);
|
||||
if(!SC_MatchToken("(")) Sys_Error ("ParseBrush: error parsing %d", b->brushnum );
|
||||
if (i != 0) Com_GetToken (true);
|
||||
if(!Com_MatchToken("(")) Sys_Error ("ParseBrush: error parsing %d", b->brushnum );
|
||||
|
||||
for (j=0 ; j<3 ; j++)
|
||||
{
|
||||
SC_GetToken (false);
|
||||
planepts[i][j] = atof(SC_Token());
|
||||
Com_GetToken (false);
|
||||
planepts[i][j] = atof(com_token);
|
||||
}
|
||||
|
||||
SC_GetToken (false);
|
||||
if(!SC_MatchToken(")"))Sys_Error ("parsing brush");
|
||||
Com_GetToken (false);
|
||||
if(!Com_MatchToken(")"))Sys_Error ("parsing brush");
|
||||
}
|
||||
|
||||
// read the texturedef
|
||||
SC_GetToken (false);
|
||||
strcpy (td.name, SC_Token());
|
||||
Com_GetToken (false);
|
||||
strcpy (td.name, com_token);
|
||||
|
||||
if(g_mapversion == VALVE_FORMAT) // Worldcraft 2.2+
|
||||
{
|
||||
// texture U axis
|
||||
SC_GetToken(false);
|
||||
if (strcmp(SC_Token(), "[")) Sys_Error("missing '[' in texturedef (U)");
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.UAxis[0] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.UAxis[1] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.UAxis[2] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.shift[0] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
if (strcmp(SC_Token(), "]")) Sys_Error("missing ']' in texturedef (U)");
|
||||
Com_GetToken(false);
|
||||
if (strcmp(com_token, "[")) Sys_Error("missing '[' in texturedef (U)");
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.UAxis[0] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.UAxis[1] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.UAxis[2] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.shift[0] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
if (strcmp(com_token, "]")) Sys_Error("missing ']' in texturedef (U)");
|
||||
|
||||
// texture V axis
|
||||
SC_GetToken(false);
|
||||
if (strcmp(SC_Token(), "[")) Sys_Error("missing '[' in texturedef (V)");
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.VAxis[0] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.VAxis[1] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.VAxis[2] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.shift[1] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
if (strcmp(SC_Token(), "]")) Sys_Error("missing ']' in texturedef (V)");
|
||||
Com_GetToken(false);
|
||||
if (strcmp(com_token, "[")) Sys_Error("missing '[' in texturedef (V)");
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.VAxis[0] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.VAxis[1] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.VAxis[2] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.shift[1] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
if (strcmp(com_token, "]")) Sys_Error("missing ']' in texturedef (V)");
|
||||
|
||||
// Texture rotation is implicit in U/V axes.
|
||||
SC_GetToken(false);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.rotate = 0;
|
||||
|
||||
// texure scale
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.scale[0] = atof(SC_Token());
|
||||
SC_GetToken(false);
|
||||
td.vects.valve.scale[1] = atof(SC_Token());
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.scale[0] = atof(com_token);
|
||||
Com_GetToken(false);
|
||||
td.vects.valve.scale[1] = atof(com_token);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Worldcraft 2.1-, Radiant
|
||||
SC_GetToken (false);
|
||||
td.vects.valve.shift[0] = atof(SC_Token());
|
||||
SC_GetToken (false);
|
||||
td.vects.valve.shift[1] = atof(SC_Token());
|
||||
SC_GetToken (false);
|
||||
td.vects.valve.rotate = atof(SC_Token());
|
||||
SC_GetToken (false);
|
||||
td.vects.valve.scale[0] = atof(SC_Token());
|
||||
SC_GetToken (false);
|
||||
td.vects.valve.scale[1] = atof(SC_Token());
|
||||
Com_GetToken (false);
|
||||
td.vects.valve.shift[0] = atof(com_token);
|
||||
Com_GetToken (false);
|
||||
td.vects.valve.shift[1] = atof(com_token);
|
||||
Com_GetToken (false);
|
||||
td.vects.valve.rotate = atof(com_token);
|
||||
Com_GetToken (false);
|
||||
td.vects.valve.scale[0] = atof(com_token);
|
||||
Com_GetToken (false);
|
||||
td.vects.valve.scale[1] = atof(com_token);
|
||||
}
|
||||
|
||||
if ((g_TXcommand == '1' || g_TXcommand == '2'))
|
||||
|
@ -680,13 +680,13 @@ void ParseBrush (bsp_entity_t *mapent)
|
|||
|
||||
//Msg("flags %d, value %d, contents %d\n", td.flags, td.value, side->contents );
|
||||
|
||||
if (SC_TryToken()) //first SC_Token() will be get automatically
|
||||
if (Com_TryToken()) //first com_token will be get automatically
|
||||
{
|
||||
side->contents = atoi(SC_Token());
|
||||
SC_GetToken (false);
|
||||
side->surf = td.flags = atoi(SC_Token());
|
||||
SC_GetToken (false);
|
||||
td.value = atoi(SC_Token());
|
||||
side->contents = atoi(com_token);
|
||||
Com_GetToken (false);
|
||||
side->surf = td.flags = atoi(com_token);
|
||||
Com_GetToken (false);
|
||||
td.value = atoi(com_token);
|
||||
}
|
||||
|
||||
// translucent objects are automatically classified as detail
|
||||
|
@ -889,9 +889,9 @@ bool ParseMapEntity (void)
|
|||
vec_t newdist;
|
||||
mapbrush_t *b;
|
||||
|
||||
if (!SC_GetToken (true)) return false;
|
||||
if (!Com_GetToken (true)) return false;
|
||||
|
||||
if(!SC_MatchToken( "{" )) Sys_Error ("ParseEntity: { not found");
|
||||
if(!Com_MatchToken( "{" )) Sys_Error ("ParseEntity: { not found");
|
||||
|
||||
if (num_entities == MAX_MAP_ENTITIES)
|
||||
Sys_Error ("num_entities == MAX_MAP_ENTITIES");
|
||||
|
@ -909,9 +909,9 @@ bool ParseMapEntity (void)
|
|||
|
||||
do
|
||||
{
|
||||
if (!SC_GetToken (true)) Sys_Error ("ParseEntity: EOF without closing brace");
|
||||
if (SC_MatchToken( "}")) break;
|
||||
if (SC_MatchToken( "{")) ParseBrush (mapent);
|
||||
if (!Com_GetToken (true)) Sys_Error ("ParseEntity: EOF without closing brace");
|
||||
if (Com_MatchToken( "}")) break;
|
||||
if (Com_MatchToken( "{")) ParseBrush (mapent);
|
||||
else
|
||||
{
|
||||
e = ParseEpair ();
|
||||
|
@ -993,7 +993,7 @@ void LoadMapFile (void)
|
|||
char path[MAX_SYSPATH];
|
||||
|
||||
sprintf (path, "maps/%s.map", gs_mapname );
|
||||
load = FS_LoadScript(path, NULL, 0);
|
||||
load = Com_LoadScript(path, NULL, 0);
|
||||
|
||||
nummapbrushsides = 0;
|
||||
num_entities = 0;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "bsplib.h"
|
||||
#include "ref_rgbdata.h"
|
||||
|
||||
vec3_t texture_reflectivity[MAX_MAP_TEXINFO];
|
||||
|
||||
|
|
|
@ -16,7 +16,7 @@ portal_t *AllocPortal (void)
|
|||
{
|
||||
portal_t *p;
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_active_portals++;
|
||||
if (c_active_portals > c_peak_portals)
|
||||
c_peak_portals = c_active_portals;
|
||||
|
@ -30,7 +30,7 @@ void FreePortal (portal_t *p)
|
|||
{
|
||||
if (p->winding)
|
||||
FreeWinding (p->winding);
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_active_portals--;
|
||||
Free (p);
|
||||
}
|
||||
|
@ -866,9 +866,6 @@ void EmitAreaPortals (node_t *headnode)
|
|||
}
|
||||
dareas[i].numareaportals = numareaportals - dareas[i].firstareaportal;
|
||||
}
|
||||
|
||||
MsgDev(D_INFO, "%5i numareas\n", numareas);
|
||||
MsgDev(D_INFO, "%5i numareaportals\n", numareaportals);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -7,7 +7,6 @@ int entity_num;
|
|||
bool onlyents;
|
||||
char path[MAX_SYSPATH];
|
||||
node_t *block_nodes[10][10];
|
||||
static double start, end;
|
||||
|
||||
bool full_compile = false;
|
||||
bool onlyents = false;
|
||||
|
@ -311,9 +310,8 @@ bool PrepareBSPModel ( const char *dir, const char *name, byte params )
|
|||
onlyrad = (params & BSP_ONLYRAD) ? true : false;
|
||||
full_compile = (params & BSP_FULLCOMPILE) ? true : false;
|
||||
|
||||
//don't worry about that
|
||||
// don't worry about that
|
||||
FS_LoadGameInfo("gameinfo.txt");
|
||||
start = Sys_DoubleTime();
|
||||
|
||||
numshaders = LoadShaderInfo();
|
||||
Msg( "%5i shaderInfo\n", numshaders );
|
||||
|
@ -346,8 +344,5 @@ bool CompileBSPModel ( void )
|
|||
remove (path);
|
||||
}
|
||||
|
||||
end = Sys_DoubleTime();
|
||||
Msg ("%5.1f seconds elapsed\n", end-start);
|
||||
|
||||
return true;
|
||||
}
|
|
@ -309,13 +309,13 @@ void LoadPortals (void)
|
|||
visplane_t plane;
|
||||
|
||||
sprintf (path, "maps/%s.prt", gs_mapname );
|
||||
load = FS_LoadScript( path, NULL, 0 );
|
||||
load = Com_LoadScript( path, NULL, 0 );
|
||||
if (!load) Sys_Error ("LoadPortals: couldn't read %s\n", path);
|
||||
Msg ("reading %s\n", path);
|
||||
|
||||
strcpy(magic, SC_GetToken( true ));
|
||||
portalclusters = atoi(SC_GetToken( true ));
|
||||
numportals = atoi(SC_GetToken( true ));
|
||||
strcpy(magic, Com_GetToken( true ));
|
||||
portalclusters = atoi(Com_GetToken( true ));
|
||||
numportals = atoi(Com_GetToken( true ));
|
||||
|
||||
if (!portalclusters && !numportals) Sys_Error ("LoadPortals: failed to read header");
|
||||
if (strcmp(magic, PORTALFILE)) Sys_Error ("LoadPortals: not a portal file");
|
||||
|
@ -345,9 +345,9 @@ void LoadPortals (void)
|
|||
|
||||
for (i = 0, p = portals; i < numportals; i++)
|
||||
{
|
||||
numpoints = atoi(SC_GetToken( true )); //newline
|
||||
leafnums[0] = atoi(SC_GetToken( false ));
|
||||
leafnums[1] = atoi(SC_GetToken( false ));
|
||||
numpoints = atoi(Com_GetToken( true )); //newline
|
||||
leafnums[0] = atoi(Com_GetToken( false ));
|
||||
leafnums[1] = atoi(Com_GetToken( false ));
|
||||
|
||||
//Msg("%d %d %d ", numpoints, leafnums[0], leafnums[1] );
|
||||
|
||||
|
@ -367,16 +367,16 @@ void LoadPortals (void)
|
|||
|
||||
// scanf into double, then assign to vec_t
|
||||
// so we don't care what size vec_t is
|
||||
SC_GetToken( false ); //get '(' symbol
|
||||
if(!SC_MatchToken( "(" )) Sys_Error ("LoadPortals: not found ( reading portal %i", i);
|
||||
v[0] = atof(SC_GetToken( false ));
|
||||
v[1] = atof(SC_GetToken( false ));
|
||||
v[2] = atof(SC_GetToken( false ));
|
||||
Com_GetToken( false ); //get '(' symbol
|
||||
if(!Com_MatchToken( "(" )) Sys_Error ("LoadPortals: not found ( reading portal %i", i);
|
||||
v[0] = atof(Com_GetToken( false ));
|
||||
v[1] = atof(Com_GetToken( false ));
|
||||
v[2] = atof(Com_GetToken( false ));
|
||||
|
||||
//Msg("( %g %g %g )", v[0], v[1], v[2] );
|
||||
|
||||
SC_GetToken( false );
|
||||
if(!SC_MatchToken( ")" )) Sys_Error ("LoadPortals: not found ) reading portal %i", i);
|
||||
Com_GetToken( false );
|
||||
if(!Com_MatchToken( ")" )) Sys_Error ("LoadPortals: not found ) reading portal %i", i);
|
||||
|
||||
for (k = 0; k < 3; k++) w->points[j][k] = v[k];
|
||||
}
|
||||
|
|
|
@ -118,7 +118,7 @@ static void ParseShaderFile( char *filename )
|
|||
char name[128];
|
||||
shader_t *si;
|
||||
|
||||
bool load = FS_LoadScript( filename, NULL, 0 );
|
||||
bool load = Com_LoadScript( filename, NULL, 0 );
|
||||
|
||||
if( load )
|
||||
{
|
||||
|
@ -128,13 +128,13 @@ static void ParseShaderFile( char *filename )
|
|||
|
||||
while ( load )
|
||||
{
|
||||
if ( !SC_GetToken( true )) break;
|
||||
if ( !Com_GetToken( true )) break;
|
||||
|
||||
si = AllocShaderInfo();
|
||||
strcpy( si->name, SC_Token() );
|
||||
SC_GetToken( true );
|
||||
strcpy( si->name, com_token );
|
||||
Com_GetToken( true );
|
||||
|
||||
if(!SC_MatchToken( "{" ))
|
||||
if(!Com_MatchToken( "{" ))
|
||||
{
|
||||
Msg("ParseShaderFile: shader %s without opening brace!\n", si->name );
|
||||
continue;
|
||||
|
@ -142,32 +142,32 @@ static void ParseShaderFile( char *filename )
|
|||
|
||||
while ( 1 )
|
||||
{
|
||||
if ( !SC_GetToken( true ) )break;
|
||||
if ( !strcmp( SC_Token(), "}" ) ) break;
|
||||
if ( !Com_GetToken( true ) )break;
|
||||
if ( !strcmp( com_token, "}" ) ) break;
|
||||
|
||||
// skip internal braced sections
|
||||
if ( !strcmp( SC_Token(), "{" ) )
|
||||
if ( !strcmp( com_token, "{" ) )
|
||||
{
|
||||
si->hasPasses = true;
|
||||
while ( 1 )
|
||||
{
|
||||
if ( !SC_GetToken( true )) break;
|
||||
if ( !strcmp( SC_Token(), "}" )) break;
|
||||
if ( !Com_GetToken( true )) break;
|
||||
if ( !strcmp( com_token, "}" )) break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( !stricmp( SC_Token(), "nextframe" ))
|
||||
if ( !stricmp( com_token, "nextframe" ))
|
||||
{
|
||||
SC_GetToken( false );
|
||||
strcpy(si->nextframe, SC_Token() );
|
||||
Com_GetToken( false );
|
||||
strcpy(si->nextframe, com_token );
|
||||
}
|
||||
if ( !stricmp( SC_Token(), "surfaceparm" ))
|
||||
if ( !stricmp( com_token, "surfaceparm" ))
|
||||
{
|
||||
SC_GetToken( false );
|
||||
Com_GetToken( false );
|
||||
for ( i = 0 ; i < numInfoParms ; i++ )
|
||||
{
|
||||
if ( !stricmp( SC_Token(), infoParms[i].name ))
|
||||
if ( !stricmp( com_token, infoParms[i].name ))
|
||||
{
|
||||
si->surfaceFlags |= infoParms[i].surfaceFlags;
|
||||
si->contents |= infoParms[i].contents;
|
||||
|
@ -179,27 +179,27 @@ static void ParseShaderFile( char *filename )
|
|||
continue;
|
||||
}
|
||||
// light color <value> <value> <value>
|
||||
if ( !stricmp( SC_Token(), "radiocity" ) )
|
||||
if ( !stricmp( com_token, "radiocity" ) )
|
||||
{
|
||||
SC_GetToken( false );
|
||||
si->color[0] = atof( SC_Token() );
|
||||
SC_GetToken( false );
|
||||
si->color[1] = atof( SC_Token() );
|
||||
SC_GetToken( false );
|
||||
si->color[2] = atof( SC_Token() );
|
||||
Com_GetToken( false );
|
||||
si->color[0] = atof( com_token );
|
||||
Com_GetToken( false );
|
||||
si->color[1] = atof( com_token );
|
||||
Com_GetToken( false );
|
||||
si->color[2] = atof( com_token );
|
||||
continue;
|
||||
}
|
||||
|
||||
// light intensity <value>
|
||||
if ( !stricmp( SC_Token(), "intensity" ))
|
||||
if ( !stricmp( com_token, "intensity" ))
|
||||
{
|
||||
SC_GetToken( false );
|
||||
si->intensity = atoi( SC_Token() );
|
||||
Com_GetToken( false );
|
||||
si->intensity = atoi( com_token );
|
||||
continue;
|
||||
}
|
||||
|
||||
// ignore all other SC_Token()s on the line
|
||||
while (SC_TryToken());
|
||||
// ignore all other com_tokens on the line
|
||||
while (Com_TryToken());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ int FindMiptex (char *name)
|
|||
|
||||
if (textureref[i].animname[0])
|
||||
{
|
||||
MsgDev(D_INFO, "FindMiptex: animation chain \"%s->%s\"\n", textureref[i].name, textureref[i].animname );
|
||||
// MsgDev(D_INFO, "FindMiptex: animation chain \"%s->%s\"\n", textureref[i].name, textureref[i].animname );
|
||||
FindMiptex(textureref[i].name);
|
||||
}
|
||||
return i;
|
||||
|
|
|
@ -83,7 +83,7 @@ void FreeTree_r (node_t *node)
|
|||
if (node->volume)
|
||||
FreeBrush (node->volume);
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_nodes--;
|
||||
Free (node);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ winding_t *AllocWinding (int points)
|
|||
winding_t *w;
|
||||
int s;
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
{
|
||||
c_winding_allocs++;
|
||||
c_winding_points += points;
|
||||
|
@ -40,7 +40,7 @@ void FreeWinding (winding_t *w)
|
|||
Sys_Error ("FreeWinding: freed a freed winding");
|
||||
*(unsigned *)w = 0xdeaddead;
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_active_windings--;
|
||||
Free (w);
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ void RemoveColinearPoints (winding_t *w)
|
|||
if (nump == w->numpoints)
|
||||
return;
|
||||
|
||||
if (numthreads == 1)
|
||||
if (GetNumThreads() == 1)
|
||||
c_removed += w->numpoints - nump;
|
||||
w->numpoints = nump;
|
||||
memcpy (w->p, p, nump*sizeof(p[0]));
|
||||
|
|
|
@ -54,7 +54,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 /opt:nowin98
|
||||
# ADD LINK32 common/zlib.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
|
||||
# ADD LINK32 msvcrt.lib /nologo /dll /profile /machine:I386 /nodefaultlib:"libc.lib" /opt:nowin98
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\common\!release
|
||||
InputPath=\XASH3D\src_main\!source\temp\common\!release\common.dll
|
||||
|
@ -90,7 +90,7 @@ BSC32=bscmake.exe
|
|||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 common/zlib.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"libc.lib" /pdbtype:sept
|
||||
# ADD LINK32 msvcrt.lib /nologo /dll /debug /machine:I386 /nodefaultlib:"msvcrtd.lib" /pdbtype:sept
|
||||
# SUBTRACT LINK32 /incremental:no /nodefaultlib
|
||||
# Begin Custom Build
|
||||
TargetDir=\XASH3D\src_main\!source\temp\common\!debug
|
||||
|
@ -133,10 +133,6 @@ SOURCE=.\bsplib\flow.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\image.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\imglib.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -1,75 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ゥ
|
||||
// archive.h - store various images
|
||||
//=======================================================================
|
||||
|
||||
#ifndef ARCHIVE_H
|
||||
#define ARCHIVE_H
|
||||
|
||||
const byte florr1_2_jpg[] = // quake2 florr1_2.wal image
|
||||
{
|
||||
0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00,
|
||||
0x01, 0x01, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0xff, 0xdb,
|
||||
0x00, 0x43, 0x00, 0x0a, 0x07, 0x07, 0x08, 0x07, 0x06, 0x0a, 0x08,
|
||||
0x08, 0x08, 0x0b, 0x0a, 0x0a, 0x0b, 0x0e, 0x18, 0x10, 0x0e, 0x0d,
|
||||
0x0d, 0x0e, 0x1d, 0x15, 0x16, 0x11, 0x18, 0x23, 0x1f, 0x25, 0x24,
|
||||
0x22, 0x1f, 0x22, 0x21, 0x26, 0x2b, 0x37, 0x2f, 0x26, 0x29, 0x34,
|
||||
0x29, 0x21, 0x22, 0x30, 0x41, 0x31, 0x34, 0x39, 0x3b, 0x3e, 0x3e,
|
||||
0x3e, 0x25, 0x2e, 0x44, 0x49, 0x43, 0x3c, 0x48, 0x37, 0x3d, 0x3e,
|
||||
0x3b, 0xff, 0xdb, 0x00, 0x43, 0x01, 0x0a, 0x0b, 0x0b, 0x0e, 0x0d,
|
||||
0x0e, 0x1c, 0x10, 0x10, 0x1c, 0x3b, 0x28, 0x22, 0x28, 0x3b, 0x3b,
|
||||
0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
|
||||
0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
|
||||
0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
|
||||
0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b, 0x3b,
|
||||
0x3b, 0x3b, 0x3b, 0x3b, 0xff, 0xc0, 0x00, 0x11, 0x08, 0x00, 0x40,
|
||||
0x00, 0x40, 0x03, 0x01, 0x11, 0x00, 0x02, 0x11, 0x01, 0x03, 0x11,
|
||||
0x01, 0xff, 0xc4, 0x00, 0x17, 0x00, 0x01, 0x01, 0x01, 0x01, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x01, 0x00, 0x02, 0x07, 0xff, 0xc4, 0x00, 0x25, 0x10, 0x00, 0x02,
|
||||
0x02, 0x02, 0x01, 0x03, 0x05, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01, 0x11, 0x00, 0x21, 0x31, 0x41, 0x51, 0x02,
|
||||
0x61, 0x81, 0x12, 0x22, 0x42, 0x71, 0xc1, 0x32, 0x91, 0xb1, 0xff,
|
||||
0xc4, 0x00, 0x16, 0x01, 0x01, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00,
|
||||
0x02, 0xff, 0xc4, 0x00, 0x1b, 0x11, 0x01, 0x00, 0x02, 0x03, 0x01,
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x01, 0x21, 0x11, 0x31, 0x41, 0x61, 0x71, 0xff, 0xda, 0x00,
|
||||
0x0c, 0x03, 0x01, 0x00, 0x02, 0x11, 0x03, 0x11, 0x00, 0x3f, 0x00,
|
||||
0xe7, 0x43, 0x18, 0xf2, 0x26, 0x22, 0x29, 0xb9, 0x9b, 0x43, 0x1d,
|
||||
0xde, 0x4c, 0xab, 0x82, 0xfa, 0x93, 0xc9, 0xd6, 0xa3, 0xb5, 0xa0,
|
||||
0xfb, 0xad, 0xb8, 0x41, 0x91, 0x68, 0xd4, 0x0b, 0x41, 0x0e, 0x98,
|
||||
0xc0, 0x95, 0xe9, 0xf7, 0x32, 0x63, 0xd1, 0xc0, 0xb6, 0x3c, 0xcb,
|
||||
0xa0, 0x92, 0x36, 0x05, 0xf0, 0x21, 0x4d, 0x5a, 0x5a, 0x22, 0x84,
|
||||
0xbc, 0x4c, 0x9c, 0x31, 0x0c, 0x9c, 0x13, 0x80, 0x52, 0x8e, 0x29,
|
||||
0x9e, 0xa4, 0x05, 0x83, 0x8c, 0x39, 0x46, 0x22, 0xcc, 0xe6, 0x4f,
|
||||
0xc8, 0x5d, 0xef, 0xb4, 0x66, 0x04, 0x4a, 0xb6, 0x20, 0x90, 0x25,
|
||||
0xa7, 0x1f, 0x17, 0xa0, 0xe4, 0x2c, 0xfd, 0x66, 0x1f, 0x09, 0x55,
|
||||
0x79, 0x3c, 0x66, 0x3b, 0x8c, 0x8d, 0x52, 0x40, 0x87, 0xb2, 0x25,
|
||||
0x16, 0xb4, 0x0b, 0x59, 0x96, 0x73, 0xb5, 0xa6, 0xac, 0x12, 0x09,
|
||||
0xf3, 0x2e, 0xd2, 0xe5, 0xb2, 0x70, 0xc1, 0x27, 0xf6, 0x08, 0x80,
|
||||
0xec, 0x15, 0xa8, 0xf2, 0x97, 0x6d, 0x04, 0x4e, 0x6b, 0x89, 0x52,
|
||||
0xb6, 0x6d, 0x1a, 0x99, 0x69, 0xa0, 0x87, 0x4c, 0x60, 0x4a, 0xf4,
|
||||
0xfb, 0x99, 0x31, 0xe8, 0xe0, 0x5b, 0x1e, 0x65, 0xd0, 0x49, 0x23,
|
||||
0xab, 0x5f, 0x70, 0xd1, 0xdb, 0x35, 0xfd, 0xc9, 0x12, 0x91, 0xba,
|
||||
0x3a, 0x12, 0xc9, 0xc1, 0x26, 0xd2, 0x1c, 0x44, 0x04, 0x05, 0x83,
|
||||
0x8c, 0x38, 0x46, 0x22, 0xcc, 0xe6, 0x4f, 0xc8, 0x5d, 0xef, 0xb4,
|
||||
0x66, 0x04, 0x4a, 0xb6, 0x20, 0x90, 0x25, 0xa7, 0x1f, 0x17, 0xa8,
|
||||
0xb6, 0xf7, 0xfe, 0xcb, 0x52, 0xb6, 0x86, 0x31, 0xe4, 0x42, 0x22,
|
||||
0x8c, 0xcd, 0xa1, 0xfc, 0x68, 0x5b, 0xb2, 0x65, 0x5c, 0x17, 0xd4,
|
||||
0x9e, 0x4e, 0xb5, 0x1d, 0xad, 0x1b, 0x04, 0x82, 0x7c, 0xcb, 0xb4,
|
||||
0xb9, 0x6c, 0x9c, 0x30, 0x49, 0xfd, 0x82, 0x20, 0x3b, 0x05, 0x6a,
|
||||
0x3c, 0xa5, 0xdb, 0x41, 0x13, 0x9a, 0xe2, 0x54, 0xac, 0x36, 0x8b,
|
||||
0xbe, 0x25, 0x2a, 0x09, 0x23, 0x60, 0x5f, 0x02, 0x14, 0x6d, 0x2d,
|
||||
0x11, 0x42, 0x5e, 0x26, 0x4e, 0x18, 0x86, 0x4e, 0x1a, 0x24, 0x8e,
|
||||
0xad, 0x7d, 0xc7, 0x4c, 0xed, 0x91, 0xdc, 0x67, 0x99, 0x44, 0x19,
|
||||
0x93, 0xea, 0xae, 0x6e, 0x49, 0x5b, 0xfc, 0x87, 0x6d, 0x70, 0x94,
|
||||
0xef, 0xb4, 0x67, 0x6b, 0x80, 0xe4, 0x2c, 0xfd, 0x66, 0x5f, 0x11,
|
||||
0x55, 0x79, 0x3c, 0x66, 0x3b, 0x8c, 0x8d, 0x52, 0x40, 0x87, 0xb2,
|
||||
0x25, 0x16, 0xb4, 0x8a, 0x77, 0xda, 0x13, 0xb3, 0xc4, 0x50, 0xd5,
|
||||
0x76, 0x94, 0xec, 0x46, 0x93, 0x42, 0x8a, 0xbd, 0xc9, 0x23, 0x56,
|
||||
0x01, 0x7c, 0x99, 0x10, 0x6c, 0xbc, 0x99, 0x67, 0x2b, 0x18, 0x16,
|
||||
0x8d, 0x40, 0xb5, 0x43, 0xa5, 0xf6, 0x8c, 0x09, 0x5e, 0x9f, 0x73,
|
||||
0x26, 0x3d, 0x1c, 0x7f, 0xff, 0xd9 };
|
||||
|
||||
#endif//ARCHIVE_H
|
|
@ -1,300 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// image.h - tga, pcx image headers
|
||||
//=======================================================================
|
||||
|
||||
#ifndef IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.BMP image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char id[2]; //bmfh.bfType
|
||||
dword fileSize; //bmfh.bfSize
|
||||
dword reserved0; //bmfh.bfReserved1 + bmfh.bfReserved2
|
||||
dword bitmapDataOffset; //bmfh.bfOffBits
|
||||
dword bitmapHeaderSize; //bmih.biSize
|
||||
dword width; //bmih.biWidth
|
||||
dword height; //bmih.biHeight
|
||||
word planes; //bmih.biPlanes
|
||||
word bitsPerPixel; //bmih.biBitCount
|
||||
dword compression; //bmih.biCompression
|
||||
dword bitmapDataSize; //bmih.biSizeImage
|
||||
dword hRes; //bmih.biXPelsPerMeter
|
||||
dword vRes; //bmih.biYPelsPerMeter
|
||||
dword colors; //bmih.biClrUsed
|
||||
dword importantColors; //bmih.biClrImportant
|
||||
byte palette[256][4]; //RGBQUAD palette
|
||||
} bmp_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.PCX image format (ZSoft Paintbrush)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char manufacturer;
|
||||
char version;
|
||||
char encoding;
|
||||
char bits_per_pixel;
|
||||
word xmin,ymin,xmax,ymax;
|
||||
word hres,vres;
|
||||
byte palette[48];
|
||||
char reserved;
|
||||
char color_planes;
|
||||
word bytes_per_line;
|
||||
word palette_type;
|
||||
char filler[58];
|
||||
} pcx_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.WAL image format (Wally textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct wal_s
|
||||
{
|
||||
char name[32];
|
||||
uint width, height;
|
||||
uint offsets[4]; // four mip maps stored
|
||||
char animname[32]; // next frame in animation chain
|
||||
int flags;
|
||||
int contents;
|
||||
int value;
|
||||
} wal_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.LMP image format (Quake1 lumps)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct lmp_s
|
||||
{
|
||||
uint width;
|
||||
uint height;
|
||||
} lmp_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.MIP image format (Quake1 textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct mip_s
|
||||
{
|
||||
char name[16];
|
||||
uint width, height;
|
||||
uint offsets[4]; // four mip maps stored
|
||||
} mip_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.FLAT image format (Doom I\II textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct flat_s
|
||||
{
|
||||
short width;
|
||||
short height;
|
||||
long desc; // image desc (not used)
|
||||
} flat_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.TGA image format (Truevision Targa)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct tga_s
|
||||
{
|
||||
byte id_length;
|
||||
byte colormap_type;
|
||||
byte image_type;
|
||||
word colormap_index;
|
||||
word colormap_length;
|
||||
byte colormap_size;
|
||||
word x_origin;
|
||||
word y_origin;
|
||||
word width;
|
||||
word height;
|
||||
byte pixel_size;
|
||||
byte attributes;
|
||||
} tga_t;
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.DDS image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
#define DDSHEADER ((' '<<24)+('S'<<16)+('D'<<8)+'D') // little-endian "DDS "
|
||||
|
||||
//other four-cc types
|
||||
#define TYPE_DXT1 (('1'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT1"
|
||||
#define TYPE_DXT2 (('2'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT2"
|
||||
#define TYPE_DXT3 (('3'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT3"
|
||||
#define TYPE_DXT4 (('4'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT4"
|
||||
#define TYPE_DXT5 (('5'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT5"
|
||||
|
||||
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
|
||||
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
|
||||
|
||||
|
||||
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
|
||||
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
||||
|
||||
#define DDS_CAPS 0x00000001L
|
||||
#define DDS_HEIGHT 0x00000002L
|
||||
#define DDS_WIDTH 0x00000004L
|
||||
|
||||
#define DDS_RGB 0x00000040L
|
||||
#define DDS_PIXELFORMAT 0x00001000L
|
||||
#define DDS_LUMINANCE 0x00020000L
|
||||
|
||||
#define DDS_ALPHAPIXELS 0x00000001L
|
||||
#define DDS_ALPHA 0x00000002L
|
||||
#define DDS_FOURCC 0x00000004L
|
||||
#define DDS_PITCH 0x00000008L
|
||||
#define DDS_COMPLEX 0x00000008L
|
||||
#define DDS_CUBEMAP 0x00000200L
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000400L
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000800L
|
||||
#define DDS_CUBEMAP_POSITIVEY 0x00001000L
|
||||
#define DDS_CUBEMAP_NEGATIVEY 0x00002000L
|
||||
#define DDS_CUBEMAP_POSITIVEZ 0x00004000L
|
||||
#define DDS_CUBEMAP_NEGATIVEZ 0x00008000L
|
||||
#define DDS_MIPMAPCOUNT 0x00020000L
|
||||
#define DDS_LINEARSIZE 0x00080000L
|
||||
#define DDS_VOLUME 0x00200000L
|
||||
#define DDS_MIPMAP 0x00400000L
|
||||
#define DDS_DEPTH 0x00800000L
|
||||
|
||||
typedef struct dds_pf_s
|
||||
{
|
||||
uint dwSize;
|
||||
uint dwFlags;
|
||||
uint dwFourCC;
|
||||
uint dwRGBBitCount;
|
||||
uint dwRBitMask;
|
||||
uint dwGBitMask;
|
||||
uint dwBBitMask;
|
||||
uint dwABitMask;
|
||||
} dds_pixf_t;
|
||||
|
||||
// DDCAPS2
|
||||
typedef struct dds_caps_s
|
||||
{
|
||||
uint dwCaps1;
|
||||
uint dwCaps2;
|
||||
uint dwCaps3;
|
||||
uint dwCaps4;
|
||||
} dds_caps_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint dwIdent; // must matched with DDSHEADER
|
||||
uint dwSize;
|
||||
uint dwFlags; // determines what fields are valid
|
||||
uint dwHeight;
|
||||
uint dwWidth;
|
||||
uint dwLinearSize; // Formless late-allocated optimized surface size
|
||||
uint dwDepth; // depth if a volume texture
|
||||
uint dwMipMapCount; // number of mip-map levels requested
|
||||
uint dwAlphaBitDepth; // depth of alpha buffer requested
|
||||
uint dwReserved1[10]; // reserved for future expansions
|
||||
dds_pixf_t dsPixelFormat;
|
||||
dds_caps_t dsCaps;
|
||||
uint dwTextureStage;
|
||||
} dds_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.JPG image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct huffman_table_s
|
||||
{
|
||||
// Huffman coding tables
|
||||
byte bits[16];
|
||||
byte hval[256];
|
||||
byte size[256];
|
||||
word code[256];
|
||||
|
||||
} huffman_table_t;
|
||||
|
||||
typedef struct jpg_s
|
||||
{
|
||||
// Jpeg file parameter
|
||||
file_t *file; // file
|
||||
byte *buffer; // jpg buffer
|
||||
|
||||
int width; // width image
|
||||
int height; // height image
|
||||
byte *data; // image
|
||||
int data_precision; // bit per component
|
||||
int num_components; // number component
|
||||
int restart_interval; // restart interval
|
||||
bool progressive_mode; // progressive format
|
||||
|
||||
struct
|
||||
{
|
||||
int id; // identifier
|
||||
int h; // horizontal sampling factor
|
||||
int v; // vertical sampling factor
|
||||
int t; // Quantization table selector
|
||||
int td; // DC table selector
|
||||
int ta; // AC table selector
|
||||
} component_info[3];
|
||||
|
||||
huffman_table_t hac[4]; // AC table
|
||||
huffman_table_t hdc[4]; // DC table
|
||||
|
||||
int qtable[4][64]; // Quantization table
|
||||
|
||||
struct
|
||||
{
|
||||
int ss,se; // progressive jpeg spectral selection
|
||||
int ah,al; // progressive jpeg successive approx
|
||||
} scan;
|
||||
|
||||
int dc[3];
|
||||
int curbit;
|
||||
byte curbyte;
|
||||
|
||||
} jpg_t;
|
||||
|
||||
static jpg_t jpg_file;
|
||||
|
||||
// image lib utilites
|
||||
void FS_InitImagelib( void );
|
||||
void FS_FreeImagelib( void );
|
||||
|
||||
extern byte *imagepool;
|
||||
extern uint *d_currentpal;
|
||||
void Image_GetQ1Palette( void );
|
||||
void Image_GetQ2Palette( void );
|
||||
void Image_GetPalettePCX( byte *pal );
|
||||
void Image_Copy8bitRGBA(const byte *in, byte *out, int pixels);
|
||||
void Image_RoundDimensions(int *scaled_width, int *scaled_height);
|
||||
byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outheight, int in_type);
|
||||
|
||||
#endif//IMAGE_H
|
|
@ -4,313 +4,9 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "platform.h"
|
||||
#include "basemath.h" // nearest_pow
|
||||
#include "ref_rgbdata.h"
|
||||
#include "utils.h"
|
||||
|
||||
byte palette_d1[768] =
|
||||
{
|
||||
0,0,0,31,23,11,23,15,7,75,75,75,255,255,255,27,27,27,19,19,19,11,11,11,7,7,7,47,55,31,35,43,15,23,31,7,15,23,0,79,
|
||||
59,43,71,51,35,63,43,27,255,183,183,247,171,171,243,163,163,235,151,151,231,143,143,223,135,135,219,123,123,211,115,
|
||||
115,203,107,107,199,99,99,191,91,91,187,87,87,179,79,79,175,71,71,167,63,63,163,59,59,155,51,51,151,47,47,143,43,43,
|
||||
139,35,35,131,31,31,127,27,27,119,23,23,115,19,19,107,15,15,103,11,11,95,7,7,91,7,7,83,7,7,79,0,0,71,0,0,67,0,0,255,
|
||||
235,223,255,227,211,255,219,199,255,211,187,255,207,179,255,199,167,255,191,155,255,187,147,255,179,131,247,171,123,
|
||||
239,163,115,231,155,107,223,147,99,215,139,91,207,131,83,203,127,79,191,123,75,179,115,71,171,111,67,163,107,63,155,
|
||||
99,59,143,95,55,135,87,51,127,83,47,119,79,43,107,71,39,95,67,35,83,63,31,75,55,27,63,47,23,51,43,19,43,35,15,239,
|
||||
239,239,231,231,231,223,223,223,219,219,219,211,211,211,203,203,203,199,199,199,191,191,191,183,183,183,179,179,179,
|
||||
171,171,171,167,167,167,159,159,159,151,151,151,147,147,147,139,139,139,131,131,131,127,127,127,119,119,119,111,111,
|
||||
111,107,107,107,99,99,99,91,91,91,87,87,87,79,79,79,71,71,71,67,67,67,59,59,59,55,55,55,47,47,47,39,39,39,35,35,35,
|
||||
119,255,111,111,239,103,103,223,95,95,207,87,91,191,79,83,175,71,75,159,63,67,147,55,63,131,47,55,115,43,47,99,35,39,
|
||||
83,27,31,67,23,23,51,15,19,35,11,11,23,7,191,167,143,183,159,135,175,151,127,167,143,119,159,135,111,155,127,107,147,
|
||||
123,99,139,115,91,131,107,87,123,99,79,119,95,75,111,87,67,103,83,63,95,75,55,87,67,51,83,63,47,159,131,99,143,119,83,
|
||||
131,107,75,119,95,63,103,83,51,91,71,43,79,59,35,67,51,27,123,127,99,111,115,87,103,107,79,91,99,71,83,87,59,71,79,51,
|
||||
63,71,43,55,63,39,255,255,115,235,219,87,215,187,67,195,155,47,175,123,31,155,91,19,135,67,7,115,43,0,255,255,255,255,
|
||||
219,219,255,187,187,255,155,155,255,123,123,255,95,95,255,63,63,255,31,31,255,0,0,239,0,0,227,0,0,215,0,0,203,0,0,191,
|
||||
0,0,179,0,0,167,0,0,155,0,0,139,0,0,127,0,0,115,0,0,103,0,0,91,0,0,79,0,0,67,0,0,231,231,255,199,199,255,171,171,255,
|
||||
143,143,255,115,115,255,83,83,255,55,55,255,27,27,255,0,0,255,0,0,227,0,0,203,0,0,179,0,0,155,0,0,131,0,0,107,0,0,83,
|
||||
255,255,255,255,235,219,255,215,187,255,199,155,255,179,123,255,163,91,255,143,59,255,127,27,243,115,23,235,111,15,
|
||||
223,103,15,215,95,11,203,87,7,195,79,0,183,71,0,175,67,0,255,255,255,255,255,215,255,255,179,255,255,143,255,255,107,
|
||||
255,255,71,255,255,35,255,255,0,167,63,0,159,55,0,147,47,0,135,35,0,79,59,39,67,47,27,55,35,19,47,27,11,0,0,83,0,0,71,
|
||||
0,0,59,0,0,47,0,0,35,0,0,23,0,0,11,0,255,255,255,159,67,255,231,75,255,123,255,255,0,255,207,0,207,159,0,155,111,0,107,
|
||||
167,107,107
|
||||
};
|
||||
|
||||
byte palette_q1[768] =
|
||||
{
|
||||
0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,
|
||||
171,171,187,187,187,203,203,203,219,219,219,235,235,235,15,11,7,23,15,11,31,23,11,39,27,15,47,35,19,55,43,23,63,
|
||||
47,23,75,55,27,83,59,27,91,67,31,99,75,31,107,83,31,115,87,31,123,95,35,131,103,35,143,111,35,11,11,15,19,19,27,
|
||||
27,27,39,39,39,51,47,47,63,55,55,75,63,63,87,71,71,103,79,79,115,91,91,127,99,99,139,107,107,151,115,115,163,123,
|
||||
123,175,131,131,187,139,139,203,0,0,0,7,7,0,11,11,0,19,19,0,27,27,0,35,35,0,43,43,7,47,47,7,55,55,7,63,63,7,71,71,
|
||||
7,75,75,11,83,83,11,91,91,11,99,99,11,107,107,15,7,0,0,15,0,0,23,0,0,31,0,0,39,0,0,47,0,0,55,0,0,63,0,0,71,0,0,79,
|
||||
0,0,87,0,0,95,0,0,103,0,0,111,0,0,119,0,0,127,0,0,19,19,0,27,27,0,35,35,0,47,43,0,55,47,0,67,55,0,75,59,7,87,67,7,
|
||||
95,71,7,107,75,11,119,83,15,131,87,19,139,91,19,151,95,27,163,99,31,175,103,35,35,19,7,47,23,11,59,31,15,75,35,19,
|
||||
87,43,23,99,47,31,115,55,35,127,59,43,143,67,51,159,79,51,175,99,47,191,119,47,207,143,43,223,171,39,239,203,31,255,
|
||||
243,27,11,7,0,27,19,0,43,35,15,55,43,19,71,51,27,83,55,35,99,63,43,111,71,51,127,83,63,139,95,71,155,107,83,167,123,
|
||||
95,183,135,107,195,147,123,211,163,139,227,179,151,171,139,163,159,127,151,147,115,135,139,103,123,127,91,111,119,
|
||||
83,99,107,75,87,95,63,75,87,55,67,75,47,55,67,39,47,55,31,35,43,23,27,35,19,19,23,11,11,15,7,7,187,115,159,175,107,
|
||||
143,163,95,131,151,87,119,139,79,107,127,75,95,115,67,83,107,59,75,95,51,63,83,43,55,71,35,43,59,31,35,47,23,27,35,
|
||||
19,19,23,11,11,15,7,7,219,195,187,203,179,167,191,163,155,175,151,139,163,135,123,151,123,111,135,111,95,123,99,83,
|
||||
107,87,71,95,75,59,83,63,51,67,51,39,55,43,31,39,31,23,27,19,15,15,11,7,111,131,123,103,123,111,95,115,103,87,107,
|
||||
95,79,99,87,71,91,79,63,83,71,55,75,63,47,67,55,43,59,47,35,51,39,31,43,31,23,35,23,15,27,19,11,19,11,7,11,7,255,
|
||||
243,27,239,223,23,219,203,19,203,183,15,187,167,15,171,151,11,155,131,7,139,115,7,123,99,7,107,83,0,91,71,0,75,55,
|
||||
0,59,43,0,43,31,0,27,15,0,11,7,0,0,0,255,11,11,239,19,19,223,27,27,207,35,35,191,43,43,175,47,47,159,47,47,143,47,
|
||||
47,127,47,47,111,47,47,95,43,43,79,35,35,63,27,27,47,19,19,31,11,11,15,43,0,0,59,0,0,75,7,0,95,7,0,111,15,0,127,23,
|
||||
7,147,31,7,163,39,11,183,51,15,195,75,27,207,99,43,219,127,59,227,151,79,231,171,95,239,191,119,247,211,139,167,123,
|
||||
59,183,155,55,199,195,55,231,227,87,127,191,255,171,231,255,215,255,255,103,0,0,139,0,0,179,0,0,215,0,0,255,0,0,255,
|
||||
243,147,255,247,199,255,255,255,159,91,83
|
||||
};
|
||||
|
||||
byte palette_q2[768] =
|
||||
{
|
||||
0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,171,
|
||||
171,187,187,187,203,203,203,219,219,219,235,235,235,99,75,35,91,67,31,83,63,31,79,59,27,71,55,27,63,47,23,59,43,23,
|
||||
51,39,19,47,35,19,43,31,19,39,27,15,35,23,15,27,19,11,23,15,11,19,15,7,15,11,7,95,95,111,91,91,103,91,83,95,87,79,91,
|
||||
83,75,83,79,71,75,71,63,67,63,59,59,59,55,55,51,47,47,47,43,43,39,39,39,35,35,35,27,27,27,23,23,23,19,19,19,143,119,
|
||||
83,123,99,67,115,91,59,103,79,47,207,151,75,167,123,59,139,103,47,111,83,39,235,159,39,203,139,35,175,119,31,147,99,
|
||||
27,119,79,23,91,59,15,63,39,11,35,23,7,167,59,43,159,47,35,151,43,27,139,39,19,127,31,15,115,23,11,103,23,7,87,19,0,
|
||||
75,15,0,67,15,0,59,15,0,51,11,0,43,11,0,35,11,0,27,7,0,19,7,0,123,95,75,115,87,67,107,83,63,103,79,59,95,71,55,87,67,
|
||||
51,83,63,47,75,55,43,67,51,39,63,47,35,55,39,27,47,35,23,39,27,19,31,23,15,23,15,11,15,11,7,111,59,23,95,55,23,83,47,
|
||||
23,67,43,23,55,35,19,39,27,15,27,19,11,15,11,7,179,91,79,191,123,111,203,155,147,215,187,183,203,215,223,179,199,211,
|
||||
159,183,195,135,167,183,115,151,167,91,135,155,71,119,139,47,103,127,23,83,111,19,75,103,15,67,91,11,63,83,7,55,75,7,
|
||||
47,63,7,39,51,0,31,43,0,23,31,0,15,19,0,7,11,0,0,0,139,87,87,131,79,79,123,71,71,115,67,67,107,59,59,99,51,51,91,47,
|
||||
47,87,43,43,75,35,35,63,31,31,51,27,27,43,19,19,31,15,15,19,11,11,11,7,7,0,0,0,151,159,123,143,151,115,135,139,107,
|
||||
127,131,99,119,123,95,115,115,87,107,107,79,99,99,71,91,91,67,79,79,59,67,67,51,55,55,43,47,47,35,35,35,27,23,23,19,
|
||||
15,15,11,159,75,63,147,67,55,139,59,47,127,55,39,119,47,35,107,43,27,99,35,23,87,31,19,79,27,15,67,23,11,55,19,11,43,
|
||||
15,7,31,11,7,23,7,0,11,0,0,0,0,0,119,123,207,111,115,195,103,107,183,99,99,167,91,91,155,83,87,143,75,79,127,71,71,
|
||||
115,63,63,103,55,55,87,47,47,75,39,39,63,35,31,47,27,23,35,19,15,23,11,7,7,155,171,123,143,159,111,135,151,99,123,
|
||||
139,87,115,131,75,103,119,67,95,111,59,87,103,51,75,91,39,63,79,27,55,67,19,47,59,11,35,47,7,27,35,0,19,23,0,11,15,
|
||||
0,0,255,0,35,231,15,63,211,27,83,187,39,95,167,47,95,143,51,95,123,51,255,255,255,255,255,211,255,255,167,255,255,
|
||||
127,255,255,83,255,255,39,255,235,31,255,215,23,255,191,15,255,171,7,255,147,0,239,127,0,227,107,0,211,87,0,199,71,
|
||||
0,183,59,0,171,43,0,155,31,0,143,23,0,127,15,0,115,7,0,95,0,0,71,0,0,47,0,0,27,0,0,239,0,0,55,55,255,255,0,0,0,0,255,
|
||||
43,43,35,27,27,23,19,19,15,235,151,127,195,115,83,159,87,51,123,63,27,235,211,199,199,171,155,167,139,119,135,107,87,
|
||||
159,91,83
|
||||
};
|
||||
|
||||
uint d_8toD1table[256];
|
||||
uint d_8toQ1table[256];
|
||||
uint d_8toQ2table[256];
|
||||
uint d_8to24table[256];
|
||||
uint *d_currentpal;
|
||||
bool d1palette_init = false;
|
||||
bool q1palette_init = false;
|
||||
bool q2palette_init = false;
|
||||
|
||||
void Image_GetPalette( byte *pal, uint *d_table )
|
||||
{
|
||||
int i;
|
||||
byte rgba[4];
|
||||
|
||||
// setup palette
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
rgba[0] = 0xFF;
|
||||
rgba[3] = pal[i*3+0];
|
||||
rgba[2] = pal[i*3+1];
|
||||
rgba[1] = pal[i*3+2];
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
}
|
||||
}
|
||||
|
||||
void Image_GetD1Palette( void )
|
||||
{
|
||||
if(!d1palette_init)
|
||||
{
|
||||
Image_GetPalette( palette_d1, d_8toD1table );
|
||||
d_8toD1table[255] = 247; // 247 is transparent
|
||||
d1palette_init = true;
|
||||
}
|
||||
d_currentpal = d_8toD1table;
|
||||
}
|
||||
|
||||
void Image_GetQ1Palette( void )
|
||||
{
|
||||
if(!q1palette_init)
|
||||
{
|
||||
Image_GetPalette( palette_q1, d_8toQ1table );
|
||||
d_8toQ1table[255] = 0; // 255 is transparent
|
||||
q1palette_init = true;
|
||||
}
|
||||
d_currentpal = d_8toQ1table;
|
||||
}
|
||||
|
||||
void Image_GetQ2Palette( void )
|
||||
{
|
||||
if(!q2palette_init)
|
||||
{
|
||||
Image_GetPalette( palette_q2, d_8toQ2table );
|
||||
d_8toQ2table[255] &= LittleLong(0xffffff);
|
||||
q2palette_init = true;
|
||||
}
|
||||
d_currentpal = d_8toQ2table;
|
||||
}
|
||||
|
||||
void Image_GetPalettePCX( byte *pal )
|
||||
{
|
||||
if(pal)
|
||||
{
|
||||
Image_GetPalette( pal, d_8to24table );
|
||||
d_8to24table[255] &= LittleLong(0xffffff);
|
||||
d_currentpal = d_8to24table;
|
||||
}
|
||||
else Image_GetQ2Palette();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Image_Copy8bitRGBA
|
||||
|
||||
NOTE: must call Image_GetQ2Palette or Image_GetQ1Palette
|
||||
before used
|
||||
============
|
||||
*/
|
||||
void Image_Copy8bitRGBA(const byte *in, byte *out, int pixels)
|
||||
{
|
||||
int *iout = (int *)out;
|
||||
|
||||
if(!d_currentpal)
|
||||
{
|
||||
MsgDev(D_ERROR,"Image_Copy8bitRGBA: no palette set\n");
|
||||
return;
|
||||
}
|
||||
|
||||
while (pixels >= 8)
|
||||
{
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
iout[2] = d_currentpal[in[2]];
|
||||
iout[3] = d_currentpal[in[3]];
|
||||
iout[4] = d_currentpal[in[4]];
|
||||
iout[5] = d_currentpal[in[5]];
|
||||
iout[6] = d_currentpal[in[6]];
|
||||
iout[7] = d_currentpal[in[7]];
|
||||
in += 8;
|
||||
iout += 8;
|
||||
pixels -= 8;
|
||||
}
|
||||
if (pixels & 4)
|
||||
{
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
iout[2] = d_currentpal[in[2]];
|
||||
iout[3] = d_currentpal[in[3]];
|
||||
in += 4;
|
||||
iout += 4;
|
||||
}
|
||||
if (pixels & 2)
|
||||
{
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
in += 2;
|
||||
iout += 2;
|
||||
}
|
||||
if (pixels & 1)
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
}
|
||||
|
||||
|
||||
void Image_RoundDimensions(int *scaled_width, int *scaled_height)
|
||||
{
|
||||
int width = *scaled_width;
|
||||
int height = *scaled_height;
|
||||
|
||||
width = nearest_pow( width );
|
||||
height = nearest_pow( height);
|
||||
|
||||
*scaled_width = bound(1, width, 4096 );
|
||||
*scaled_height = bound(1, height, 4096 );
|
||||
}
|
||||
|
||||
byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outheight, int in_type )
|
||||
{
|
||||
int i, j;
|
||||
uint frac, fracstep;
|
||||
uint *inrow1, *inrow2;
|
||||
byte *pix1, *pix2, *pix3, *pix4;
|
||||
uint *out, *buf, p1[4096], p2[4096];
|
||||
|
||||
// check for buffers
|
||||
if(!in) return NULL;
|
||||
|
||||
// nothing to resample ?
|
||||
if (inwidth == outwidth && inheight == outheight)
|
||||
return (byte *)in;
|
||||
|
||||
// can't resample compressed formats
|
||||
if(in_type != PF_RGBA_32) return NULL;
|
||||
|
||||
// malloc new buffer
|
||||
out = buf = (uint *)Mem_Alloc( imagepool, outwidth * outheight * 4 );
|
||||
|
||||
fracstep = inwidth * 0x10000 / outwidth;
|
||||
frac = fracstep>>2;
|
||||
|
||||
for( i = 0; i < outwidth; i++)
|
||||
{
|
||||
p1[i] = 4 * (frac>>16);
|
||||
frac += fracstep;
|
||||
}
|
||||
frac = 3 * (fracstep>>2);
|
||||
|
||||
for( i = 0; i < outwidth; i++)
|
||||
{
|
||||
p2[i] = 4 * (frac>>16);
|
||||
frac += fracstep;
|
||||
}
|
||||
|
||||
for (i = 0; i < outheight; i++,buf += outwidth)
|
||||
{
|
||||
inrow1 = in + inwidth * (int)((i + 0.25) * inheight / outheight);
|
||||
inrow2 = in + inwidth * (int)((i + 0.75) * inheight / outheight);
|
||||
frac = fracstep>>1;
|
||||
|
||||
for (j = 0; j < outwidth; j++)
|
||||
{
|
||||
pix1 = (byte *)inrow1 + p1[j];
|
||||
pix2 = (byte *)inrow1 + p2[j];
|
||||
pix3 = (byte *)inrow2 + p1[j];
|
||||
pix4 = (byte *)inrow2 + p2[j];
|
||||
((byte *)(buf+j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0])>>2;
|
||||
((byte *)(buf+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2;
|
||||
((byte *)(buf+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2;
|
||||
((byte *)(buf+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2;
|
||||
}
|
||||
}
|
||||
return (byte *)out;
|
||||
}
|
||||
|
||||
bool Image_Processing( const char *name, rgbdata_t **pix )
|
||||
{
|
||||
int w, h;
|
||||
rgbdata_t *image = *pix;
|
||||
byte *out;
|
||||
char width[4], height[4];
|
||||
|
||||
//check for buffers
|
||||
if(!image || !image->buffer) return false;
|
||||
|
||||
w = image->width;
|
||||
h = image->height;
|
||||
|
||||
if(FS_GetParmFromCmdLine("-w", width ) && FS_GetParmFromCmdLine("-h", height ))
|
||||
{
|
||||
// custom size
|
||||
w = atoi(width);
|
||||
h = atoi(height);
|
||||
}
|
||||
else Image_RoundDimensions( &w, &h ); //auto detect new size
|
||||
|
||||
out = Image_Resample((uint *)image->buffer, image->width, image->height, w, h, image->type );
|
||||
if(out != image->buffer)
|
||||
{
|
||||
Msg("Resampling %s from[%d x %d] to[%d x %d]\n",name, image->width, image->height, w, h );
|
||||
Mem_Move( imagepool, &image->buffer, out, w * h * 4 );// update image->buffer
|
||||
image->width = w,image->height = h;
|
||||
*pix = image;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ConvertImagePixels ( byte *mempool, const char *name, byte parms )
|
||||
{
|
||||
rgbdata_t *image = FS_LoadImage( name, NULL, 0 );
|
||||
|
|
|
@ -137,13 +137,13 @@ syntax: "$type preset"
|
|||
*/
|
||||
void Cmd_Type (void)
|
||||
{
|
||||
SC_GetToken (false);
|
||||
Com_GetToken (false);
|
||||
|
||||
if (SC_MatchToken( "vp_parallel_upright" )) sprite.type = SPR_VP_PARALLEL_UPRIGHT;
|
||||
else if (SC_MatchToken( "facing_upright" )) sprite.type = SPR_FACING_UPRIGHT;
|
||||
else if (SC_MatchToken( "vp_parallel" )) sprite.type = SPR_VP_PARALLEL;
|
||||
else if (SC_MatchToken( "oriented" )) sprite.type = SPR_ORIENTED;
|
||||
else if (SC_MatchToken( "vp_parallel_oriented")) sprite.type = SPR_VP_PARALLEL_ORIENTED;
|
||||
if (Com_MatchToken( "vp_parallel_upright" )) sprite.type = SPR_VP_PARALLEL_UPRIGHT;
|
||||
else if (Com_MatchToken( "facing_upright" )) sprite.type = SPR_FACING_UPRIGHT;
|
||||
else if (Com_MatchToken( "vp_parallel" )) sprite.type = SPR_VP_PARALLEL;
|
||||
else if (Com_MatchToken( "oriented" )) sprite.type = SPR_ORIENTED;
|
||||
else if (Com_MatchToken( "vp_parallel_oriented")) sprite.type = SPR_VP_PARALLEL_ORIENTED;
|
||||
else sprite.type = SPR_VP_PARALLEL; // default
|
||||
}
|
||||
|
||||
|
@ -156,13 +156,13 @@ syntax: "$texture preset"
|
|||
*/
|
||||
void Cmd_Texture ( void )
|
||||
{
|
||||
SC_GetToken (false);
|
||||
Com_GetToken (false);
|
||||
|
||||
if (SC_MatchToken( "additive")) sprite.texFormat = SPR_ADDITIVE;
|
||||
else if (SC_MatchToken( "normal")) sprite.texFormat = SPR_NORMAL;
|
||||
else if (SC_MatchToken( "indexalpha")) sprite.texFormat = SPR_INDEXALPHA;
|
||||
else if (SC_MatchToken( "alphatest")) sprite.texFormat = SPR_ALPHTEST;
|
||||
else if (SC_MatchToken( "glow")) sprite.texFormat = SPR_ADDGLOW;
|
||||
if (Com_MatchToken( "additive")) sprite.texFormat = SPR_ADDITIVE;
|
||||
else if (Com_MatchToken( "normal")) sprite.texFormat = SPR_NORMAL;
|
||||
else if (Com_MatchToken( "indexalpha")) sprite.texFormat = SPR_INDEXALPHA;
|
||||
else if (Com_MatchToken( "alphatest")) sprite.texFormat = SPR_ALPHTEST;
|
||||
else if (Com_MatchToken( "glow")) sprite.texFormat = SPR_ADDGLOW;
|
||||
else sprite.texFormat = SPR_NORMAL; // default
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ syntax: "$framerate value"
|
|||
*/
|
||||
void Cmd_Framerate( void )
|
||||
{
|
||||
sprite.framerate = atof(SC_GetToken (false));
|
||||
sprite.framerate = atof(Com_GetToken (false));
|
||||
sprite.version = SPRITE_VERSION_XASH; // enchaned version
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ syntax "$load fire01.bmp"
|
|||
void Cmd_Load( void )
|
||||
{
|
||||
static byte origpalette[256*3];
|
||||
char *name = SC_GetToken ( false );
|
||||
char *name = Com_GetToken ( false );
|
||||
dspriteframe_t *pframe;
|
||||
int x, y, w, h, pix;
|
||||
byte *screen_p;
|
||||
|
@ -261,8 +261,8 @@ syntax: $origin "x_pos y_pos"
|
|||
|
||||
void Cmd_Offset (void)
|
||||
{
|
||||
origin_x = atoi(SC_GetToken (false));
|
||||
origin_y = atoi(SC_GetToken (false));
|
||||
origin_x = atoi(Com_GetToken (false));
|
||||
origin_y = atoi(Com_GetToken (false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -275,11 +275,11 @@ synatx: "$color r g b <alpha>"
|
|||
void Cmd_Color( void )
|
||||
{
|
||||
byte rgba[4];
|
||||
rgba[3] = atoi(SC_GetToken (false));
|
||||
rgba[2] = atoi(SC_GetToken (false));
|
||||
rgba[1] = atoi(SC_GetToken (false));
|
||||
rgba[3] = atoi(Com_GetToken (false));
|
||||
rgba[2] = atoi(Com_GetToken (false));
|
||||
rgba[1] = atoi(Com_GetToken (false));
|
||||
|
||||
if (SC_TryToken()) rgba[0] = atoi(SC_Token());
|
||||
if(Com_TryToken()) rgba[0] = atoi(com_token);
|
||||
else rgba[0] = 0xFF;//fullbright
|
||||
|
||||
// pack into one integer
|
||||
|
@ -296,7 +296,7 @@ syntax: "$spritename outname"
|
|||
*/
|
||||
void Cmd_Spritename (void)
|
||||
{
|
||||
strcpy( spriteoutname, SC_GetToken (false));
|
||||
strcpy( spriteoutname, Com_GetToken (false));
|
||||
FS_DefaultExtension( spriteoutname, ".spr" );
|
||||
}
|
||||
|
||||
|
@ -309,8 +309,8 @@ syntax: "blabla"
|
|||
*/
|
||||
void Cmd_SpriteUnknown( void )
|
||||
{
|
||||
MsgWarn("Cmd_SpriteUnknown: bad command %s\n", SC_Token());
|
||||
while(SC_TryToken());
|
||||
MsgWarn("Cmd_SpriteUnknown: bad command %s\n", com_token);
|
||||
while(Com_TryToken());
|
||||
}
|
||||
|
||||
void ResetSpriteInfo( void )
|
||||
|
@ -343,21 +343,21 @@ bool ParseSpriteScript (void)
|
|||
|
||||
while (1)
|
||||
{
|
||||
if(!SC_GetToken (true))break;
|
||||
if(!Com_GetToken (true))break;
|
||||
|
||||
if (SC_MatchToken( "$spritename" )) Cmd_Spritename();
|
||||
else if (SC_MatchToken( "$framerate" )) Cmd_Framerate();
|
||||
else if (SC_MatchToken( "$texture" )) Cmd_Texture();
|
||||
else if (SC_MatchToken( "$origin" )) Cmd_Offset();
|
||||
else if (SC_MatchToken( "$color" )) Cmd_Color();
|
||||
else if (SC_MatchToken( "$load" )) Cmd_Load();
|
||||
else if (SC_MatchToken( "$type" )) Cmd_Type();
|
||||
else if(SC_MatchToken( "$modelname" ))//check for studiomdl script
|
||||
if (Com_MatchToken( "$spritename" )) Cmd_Spritename();
|
||||
else if (Com_MatchToken( "$framerate" )) Cmd_Framerate();
|
||||
else if (Com_MatchToken( "$texture" )) Cmd_Texture();
|
||||
else if (Com_MatchToken( "$origin" )) Cmd_Offset();
|
||||
else if (Com_MatchToken( "$color" )) Cmd_Color();
|
||||
else if (Com_MatchToken( "$load" )) Cmd_Load();
|
||||
else if (Com_MatchToken( "$type" )) Cmd_Type();
|
||||
else if(Com_MatchToken( "$modelname" ))//check for studiomdl script
|
||||
{
|
||||
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
|
||||
return false;
|
||||
}
|
||||
else if(SC_MatchToken( "$body" ))//check for studiomdl script
|
||||
else if(Com_MatchToken( "$body" ))//check for studiomdl script
|
||||
{
|
||||
Msg("%s probably studio qc.script, skipping...\n", gs_mapname );
|
||||
return false;
|
||||
|
@ -382,7 +382,7 @@ bool CompileCurrentSprite( const char *name )
|
|||
|
||||
if(name) strcpy( gs_mapname, name );
|
||||
FS_DefaultExtension( gs_mapname, ".qc" );
|
||||
load = FS_LoadScript( gs_mapname, NULL, 0 );
|
||||
load = Com_LoadScript( gs_mapname, NULL, 0 );
|
||||
|
||||
if(load)
|
||||
{
|
||||
|
|
|
@ -1348,14 +1348,14 @@ void Grab_Triangles( s_model_t *pmodel )
|
|||
vec3_t vert[3];
|
||||
vec3_t norm[3];
|
||||
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
if(SC_MatchToken( "end" )) break;//triangles end
|
||||
else if(!stricmp( ".bmp", &SC_Token()[strlen(SC_Token())-4]))
|
||||
if(Com_MatchToken( "end" )) break;//triangles end
|
||||
else if(!stricmp( ".bmp", &com_token[strlen(com_token)-4]))
|
||||
{
|
||||
//probably is texture name
|
||||
strcpy( texturename, SC_Token());
|
||||
strcpy( texturename, com_token);
|
||||
|
||||
// funky texture overrides
|
||||
for (i = 0; i < numrep; i++)
|
||||
|
@ -1377,9 +1377,9 @@ void Grab_Triangles( s_model_t *pmodel )
|
|||
MsgWarn("Grab_Triangles: triangle with invalid texname\n");
|
||||
for(i = 0; i < 3; i++)
|
||||
{
|
||||
if(!SC_GetToken( true ))
|
||||
if(!Com_GetToken( true ))
|
||||
Sys_Error( "Unexpected EOF %s at line %d\n", filename, linecount );
|
||||
while(SC_TryToken());
|
||||
while(Com_TryToken());
|
||||
linecount++;
|
||||
}
|
||||
continue;
|
||||
|
@ -1399,18 +1399,18 @@ void Grab_Triangles( s_model_t *pmodel )
|
|||
else ptriv = lookup_triangle( pmesh, pmesh->numtris ) + j;
|
||||
|
||||
//grab triangle info
|
||||
bone = atoi(SC_Token());
|
||||
p.org[0] = atof(SC_GetToken( false ));
|
||||
p.org[1] = atof(SC_GetToken( false ));
|
||||
p.org[2] = atof(SC_GetToken( false ));
|
||||
normal.org[0] = atof(SC_GetToken( false ));
|
||||
normal.org[1] = atof(SC_GetToken( false ));
|
||||
normal.org[2] = atof(SC_GetToken( false ));
|
||||
ptriv->u = atof(SC_GetToken( false ));
|
||||
ptriv->v = atof(SC_GetToken( false ));
|
||||
bone = atoi(com_token);
|
||||
p.org[0] = atof(Com_GetToken( false ));
|
||||
p.org[1] = atof(Com_GetToken( false ));
|
||||
p.org[2] = atof(Com_GetToken( false ));
|
||||
normal.org[0] = atof(Com_GetToken( false ));
|
||||
normal.org[1] = atof(Com_GetToken( false ));
|
||||
normal.org[2] = atof(Com_GetToken( false ));
|
||||
ptriv->u = atof(Com_GetToken( false ));
|
||||
ptriv->v = atof(Com_GetToken( false ));
|
||||
|
||||
// skip MilkShape additional info
|
||||
while(SC_TryToken());
|
||||
while(Com_TryToken());
|
||||
|
||||
//translate triangles
|
||||
if (bone < 0 || bone >= pmodel->numbones)
|
||||
|
@ -1444,7 +1444,7 @@ void Grab_Triangles( s_model_t *pmodel )
|
|||
|
||||
if(j < 2)
|
||||
{
|
||||
SC_GetToken( true );
|
||||
Com_GetToken( true );
|
||||
linecount++;
|
||||
}
|
||||
}
|
||||
|
@ -1464,31 +1464,31 @@ void Grab_Skeleton( s_node_t *pnodes, s_bone_t *pbones )
|
|||
|
||||
while ( 1 )
|
||||
{
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
if(SC_MatchToken( "end" )) return;//skeleton end
|
||||
else if(SC_MatchToken( "time" ))
|
||||
if(Com_MatchToken( "end" )) return;//skeleton end
|
||||
else if(Com_MatchToken( "time" ))
|
||||
{
|
||||
//check time
|
||||
time += atoi(SC_GetToken( false ));
|
||||
time += atoi(Com_GetToken( false ));
|
||||
if(time > 0) MsgWarn("Grab_Skeleton: Warning! An animation file is probably used as a reference\n");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
//grab skeleton info
|
||||
index = atoi( SC_Token());
|
||||
pbones[index].pos[0] = atof(SC_GetToken( false ));
|
||||
pbones[index].pos[1] = atof(SC_GetToken( false ));
|
||||
pbones[index].pos[2] = atof(SC_GetToken( false ));
|
||||
index = atoi( com_token);
|
||||
pbones[index].pos[0] = atof(Com_GetToken( false ));
|
||||
pbones[index].pos[1] = atof(Com_GetToken( false ));
|
||||
pbones[index].pos[2] = atof(Com_GetToken( false ));
|
||||
|
||||
scale_vertex( pbones[index].pos );
|
||||
if (pnodes[index].mirrored) VectorScale( pbones[index].pos, -1.0, pbones[index].pos );
|
||||
|
||||
pbones[index].rot[0] = atof(SC_GetToken( false ));
|
||||
pbones[index].rot[1] = atof(SC_GetToken( false ));
|
||||
pbones[index].rot[2] = atof(SC_GetToken( false ));
|
||||
pbones[index].rot[0] = atof(Com_GetToken( false ));
|
||||
pbones[index].rot[1] = atof(Com_GetToken( false ));
|
||||
pbones[index].rot[2] = atof(Com_GetToken( false ));
|
||||
|
||||
clip_rotations( pbones[index].rot );
|
||||
}
|
||||
|
@ -1506,15 +1506,15 @@ int Grab_Nodes( s_node_t *pnodes )
|
|||
|
||||
while( 1 )
|
||||
{
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
//end of nodes description
|
||||
if(SC_MatchToken( "end" )) return numbones + 1;
|
||||
if(Com_MatchToken( "end" )) return numbones + 1;
|
||||
|
||||
index = atoi(SC_Token()); //read bone index (we already have filled token)
|
||||
strcpy( name, SC_GetToken( false ));
|
||||
parent = atoi(SC_GetToken( false )); //read bone parent
|
||||
index = atoi(com_token); //read bone index (we already have filled token)
|
||||
strcpy( name, Com_GetToken( false ));
|
||||
parent = atoi(Com_GetToken( false )); //read bone parent
|
||||
|
||||
strncpy( pnodes[index].name, name, sizeof(pnodes[index].name));
|
||||
pnodes[index].parent = parent;
|
||||
|
@ -1537,7 +1537,7 @@ void Grab_Studio ( s_model_t *pmodel )
|
|||
strncpy (filename, pmodel->name, sizeof(filename));
|
||||
|
||||
FS_DefaultExtension(filename, ".smd" );
|
||||
load = FS_AddScript( filename, NULL, 0 );
|
||||
load = Com_IncludeScript( filename, NULL, 0 );
|
||||
if(!load) Sys_Error("unable to open %s\n", filename );
|
||||
Msg("grabbing %s\n", filename);
|
||||
|
||||
|
@ -1545,27 +1545,27 @@ void Grab_Studio ( s_model_t *pmodel )
|
|||
|
||||
while ( 1 )
|
||||
{
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
if (SC_MatchToken( "version" ))
|
||||
if (Com_MatchToken( "version" ))
|
||||
{
|
||||
int option = atoi(SC_GetToken( false ));
|
||||
int option = atoi(Com_GetToken( false ));
|
||||
if (option != 1) MsgWarn("Grab_Studio: %s bad version file\n", filename );
|
||||
}
|
||||
else if (SC_MatchToken( "nodes" ))
|
||||
else if (Com_MatchToken( "nodes" ))
|
||||
{
|
||||
pmodel->numbones = Grab_Nodes( pmodel->node );
|
||||
}
|
||||
else if (SC_MatchToken( "skeleton" ))
|
||||
else if (Com_MatchToken( "skeleton" ))
|
||||
{
|
||||
Grab_Skeleton( pmodel->node, pmodel->skeleton );
|
||||
}
|
||||
else if (SC_MatchToken( "triangles" ))
|
||||
else if (Com_MatchToken( "triangles" ))
|
||||
{
|
||||
Grab_Triangles( pmodel );
|
||||
}
|
||||
else MsgWarn("Grab_Studio: unknown studio command %s at line %d\n", SC_Token(), linecount );
|
||||
else MsgWarn("Grab_Studio: unknown studio command %s at line %d\n", com_token, linecount );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1579,9 +1579,9 @@ syntax: $eyeposition <x> <y> <z>
|
|||
void Cmd_Eyeposition (void)
|
||||
{
|
||||
// rotate points into frame of reference so model points down the positive x axis
|
||||
eyeposition[1] = atof (SC_GetToken (false));
|
||||
eyeposition[0] = -atof (SC_GetToken (false));
|
||||
eyeposition[2] = atof (SC_GetToken (false));
|
||||
eyeposition[1] = atof (Com_GetToken (false));
|
||||
eyeposition[0] = -atof (Com_GetToken (false));
|
||||
eyeposition[2] = atof (Com_GetToken (false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1593,30 +1593,30 @@ syntax: $modelname "outname"
|
|||
*/
|
||||
void Cmd_Modelname (void)
|
||||
{
|
||||
strcpy (modeloutname, SC_GetToken (false));
|
||||
strcpy (modeloutname, Com_GetToken (false));
|
||||
}
|
||||
|
||||
void Option_Studio( void )
|
||||
{
|
||||
if(!SC_GetToken (false)) return;
|
||||
if(!Com_GetToken (false)) return;
|
||||
|
||||
model[nummodels] = Kalloc( sizeof( s_model_t ));
|
||||
bodypart[numbodyparts].pmodel[bodypart[numbodyparts].nummodels] = model[nummodels];
|
||||
|
||||
strncpy( model[nummodels]->name, SC_Token(), sizeof(model[nummodels]->name));
|
||||
strncpy( model[nummodels]->name, com_token, sizeof(model[nummodels]->name));
|
||||
|
||||
flip_triangles = 1;
|
||||
scale_up = default_scale;
|
||||
|
||||
while(SC_TryToken())
|
||||
while(Com_TryToken())
|
||||
{
|
||||
if (SC_MatchToken( "reverse" ))
|
||||
if (Com_MatchToken( "reverse" ))
|
||||
{
|
||||
flip_triangles = 0;
|
||||
}
|
||||
else if (SC_MatchToken( "scale" ))
|
||||
else if (Com_MatchToken( "scale" ))
|
||||
{
|
||||
scale_up = atof( SC_GetToken(false));
|
||||
scale_up = atof( Com_GetToken(false));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1657,20 +1657,20 @@ void Cmd_Bodygroup( void )
|
|||
int is_started = 0;
|
||||
|
||||
Msg("cmd_bodygroup\n");
|
||||
if(!SC_TryToken()) return;
|
||||
if(!Com_TryToken()) return;
|
||||
|
||||
if (numbodyparts == 0) bodypart[numbodyparts].base = 1;
|
||||
else bodypart[numbodyparts].base = bodypart[numbodyparts-1].base * bodypart[numbodyparts-1].nummodels;
|
||||
strncpy( bodypart[numbodyparts].name, SC_Token(), sizeof(bodypart[numbodyparts].name));
|
||||
strncpy( bodypart[numbodyparts].name, com_token, sizeof(bodypart[numbodyparts].name));
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
if(!SC_GetToken(true)) return;
|
||||
if(!Com_GetToken(true)) return;
|
||||
|
||||
if(SC_MatchToken( "{" )) is_started = 1;
|
||||
else if (SC_MatchToken( "}" )) break;
|
||||
else if (SC_MatchToken("studio" )) Option_Studio();
|
||||
else if (SC_MatchToken("blank" )) Option_Blank();
|
||||
if(Com_MatchToken( "{" )) is_started = 1;
|
||||
else if (Com_MatchToken( "}" )) break;
|
||||
else if (Com_MatchToken("studio" )) Option_Studio();
|
||||
else if (Com_MatchToken("blank" )) Option_Blank();
|
||||
}
|
||||
|
||||
numbodyparts++;
|
||||
|
@ -1687,12 +1687,12 @@ syntax: $body "name" "mainref.smd"
|
|||
void Cmd_Body( void )
|
||||
{
|
||||
int is_started = 0;
|
||||
if (!SC_GetToken(false)) return;
|
||||
if (!Com_GetToken(false)) return;
|
||||
|
||||
if (numbodyparts == 0) bodypart[numbodyparts].base = 1;
|
||||
else bodypart[numbodyparts].base = bodypart[numbodyparts-1].base * bodypart[numbodyparts-1].nummodels;
|
||||
|
||||
strncpy(bodypart[numbodyparts].name, SC_Token(), sizeof(bodypart[numbodyparts].name));
|
||||
strncpy(bodypart[numbodyparts].name, com_token, sizeof(bodypart[numbodyparts].name));
|
||||
Option_Studio();
|
||||
|
||||
numbodyparts++;
|
||||
|
@ -1719,28 +1719,28 @@ void Grab_Animation( s_animation_t *panim)
|
|||
|
||||
while ( 1 )
|
||||
{
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
if(SC_MatchToken( "end" ))
|
||||
if(Com_MatchToken( "end" ))
|
||||
{
|
||||
panim->startframe = start;
|
||||
panim->endframe = end;
|
||||
return;
|
||||
}
|
||||
else if(SC_MatchToken( "time" ))
|
||||
else if(Com_MatchToken( "time" ))
|
||||
{
|
||||
t = atoi(SC_GetToken(false));
|
||||
t = atoi(Com_GetToken(false));
|
||||
}
|
||||
else
|
||||
{
|
||||
index = atoi(SC_Token());
|
||||
pos[0] = atof(SC_GetToken( false ));
|
||||
pos[1] = atof(SC_GetToken( false ));
|
||||
pos[2] = atof(SC_GetToken( false ));
|
||||
rot[0] = atof(SC_GetToken( false ));
|
||||
rot[1] = atof(SC_GetToken( false ));
|
||||
rot[2] = atof(SC_GetToken( false ));
|
||||
index = atoi(com_token);
|
||||
pos[0] = atof(Com_GetToken( false ));
|
||||
pos[1] = atof(Com_GetToken( false ));
|
||||
pos[2] = atof(Com_GetToken( false ));
|
||||
rot[0] = atof(Com_GetToken( false ));
|
||||
rot[1] = atof(Com_GetToken( false ));
|
||||
rot[2] = atof(Com_GetToken( false ));
|
||||
|
||||
if (t >= panim->startframe && t <= panim->endframe)
|
||||
{
|
||||
|
@ -1802,43 +1802,43 @@ void Option_Animation ( char *name, s_animation_t *panim )
|
|||
strncpy( filename, panim->name, sizeof(filename));
|
||||
|
||||
FS_DefaultExtension(filename, ".smd" );
|
||||
load = FS_AddScript( filename, NULL, 0 );
|
||||
if(!load)Sys_Error("unable to open %s\n", filename );
|
||||
load = Com_IncludeScript( filename, NULL, 0 );
|
||||
if(!load) Sys_Error("unable to open %s\n", filename );
|
||||
Msg("grabbing %s\n", filename);
|
||||
|
||||
linecount = 0;
|
||||
|
||||
while ( 1 )
|
||||
{
|
||||
if(!SC_GetToken( true )) break;
|
||||
if(!Com_GetToken( true )) break;
|
||||
linecount++;
|
||||
|
||||
if(SC_MatchToken( "end" )) break;
|
||||
else if (SC_MatchToken( "version" ))
|
||||
if(Com_MatchToken( "end" )) break;
|
||||
else if (Com_MatchToken( "version" ))
|
||||
{
|
||||
int option = atoi(SC_GetToken( false ));
|
||||
int option = atoi(Com_GetToken( false ));
|
||||
if (option != 1) Msg("Warning: %s bad version file\n", filename );
|
||||
}
|
||||
else if (SC_MatchToken( "nodes" ))
|
||||
else if (Com_MatchToken( "nodes" ))
|
||||
{
|
||||
panim->numbones = Grab_Nodes( panim->node );
|
||||
}
|
||||
else if (SC_MatchToken( "skeleton" ))
|
||||
else if (Com_MatchToken( "skeleton" ))
|
||||
{
|
||||
Grab_Animation( panim );
|
||||
Shift_Animation( panim );
|
||||
}
|
||||
else
|
||||
{
|
||||
MsgWarn("Option_Animation: unknown studio command : %s\n", SC_Token() );
|
||||
while(SC_TryToken());//skip other tokens at line
|
||||
MsgWarn("Option_Animation: unknown studio command : %s\n", com_token );
|
||||
while(Com_TryToken());//skip other tokens at line
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int Option_Motion ( s_sequence_t *psequence )
|
||||
{
|
||||
while (SC_TryToken()) psequence->motiontype |= lookupControl( SC_Token());
|
||||
while (Com_TryToken()) psequence->motiontype |= lookupControl( com_token);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1850,15 +1850,15 @@ int Option_Event ( s_sequence_t *psequence )
|
|||
return 0;
|
||||
}
|
||||
|
||||
psequence->event[psequence->numevents].event = atoi( SC_GetToken (false));
|
||||
psequence->event[psequence->numevents].frame = atoi(SC_GetToken (false));
|
||||
psequence->event[psequence->numevents].event = atoi( Com_GetToken (false));
|
||||
psequence->event[psequence->numevents].frame = atoi(Com_GetToken (false));
|
||||
psequence->numevents++;
|
||||
|
||||
// option token
|
||||
if (SC_TryToken())
|
||||
if (Com_TryToken())
|
||||
{
|
||||
if (SC_MatchToken( "}" )) return 1; // opps, hit the end
|
||||
strcpy( psequence->event[psequence->numevents-1].options, SC_Token());// found an option
|
||||
if (Com_MatchToken( "}" )) return 1; // opps, hit the end
|
||||
strcpy( psequence->event[psequence->numevents-1].options, com_token);// found an option
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -1866,7 +1866,7 @@ int Option_Event ( s_sequence_t *psequence )
|
|||
|
||||
int Option_Fps ( s_sequence_t *psequence )
|
||||
{
|
||||
psequence->fps = atof(SC_GetToken (false));
|
||||
psequence->fps = atof(Com_GetToken (false));
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -1878,9 +1878,9 @@ int Option_AddPivot ( s_sequence_t *psequence )
|
|||
return 0;
|
||||
}
|
||||
|
||||
psequence->pivot[psequence->numpivots].index = atoi(SC_GetToken (false));
|
||||
psequence->pivot[psequence->numpivots].start = atoi(SC_GetToken (false));
|
||||
psequence->pivot[psequence->numpivots].end = atoi(SC_GetToken (false));
|
||||
psequence->pivot[psequence->numpivots].index = atoi(Com_GetToken (false));
|
||||
psequence->pivot[psequence->numpivots].start = atoi(Com_GetToken (false));
|
||||
psequence->pivot[psequence->numpivots].end = atoi(Com_GetToken (false));
|
||||
psequence->numpivots++;
|
||||
|
||||
return 0;
|
||||
|
@ -1895,24 +1895,24 @@ syntax: $origin <x> <y> <z> (z rotate)
|
|||
*/
|
||||
void Cmd_Origin (void)
|
||||
{
|
||||
defaultadjust[0] = atof (SC_GetToken (false));
|
||||
defaultadjust[1] = atof (SC_GetToken (false));
|
||||
defaultadjust[2] = atof (SC_GetToken (false));
|
||||
defaultadjust[0] = atof (Com_GetToken (false));
|
||||
defaultadjust[1] = atof (Com_GetToken (false));
|
||||
defaultadjust[2] = atof (Com_GetToken (false));
|
||||
|
||||
if (SC_TryToken()) defaultzrotation = (atof( SC_Token()) + 90) * (M_PI / 180.0);
|
||||
if (Com_TryToken()) defaultzrotation = (atof( com_token) + 90) * (M_PI / 180.0);
|
||||
}
|
||||
|
||||
|
||||
void Option_Origin (void)
|
||||
{
|
||||
adjust[0] = atof (SC_GetToken (false));
|
||||
adjust[1] = atof (SC_GetToken (false));
|
||||
adjust[2] = atof (SC_GetToken (false));
|
||||
adjust[0] = atof (Com_GetToken (false));
|
||||
adjust[1] = atof (Com_GetToken (false));
|
||||
adjust[2] = atof (Com_GetToken (false));
|
||||
}
|
||||
|
||||
void Option_Rotate(void )
|
||||
{
|
||||
zrotation = (atof(SC_GetToken (false)) + 90) * (M_PI / 180.0);
|
||||
zrotation = (atof(Com_GetToken (false)) + 90) * (M_PI / 180.0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1924,7 +1924,7 @@ syntax: $scale <value>
|
|||
*/
|
||||
void Cmd_ScaleUp (void)
|
||||
{
|
||||
default_scale = scale_up = atof (SC_GetToken (false));
|
||||
default_scale = scale_up = atof (Com_GetToken (false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1936,13 +1936,13 @@ syntax: $rotate <value>
|
|||
*/
|
||||
void Cmd_Rotate(void)
|
||||
{
|
||||
if (!SC_GetToken(false)) return;
|
||||
zrotation = (atof(SC_Token()) + 90) * (M_PI / 180.0);
|
||||
if (!Com_GetToken(false)) return;
|
||||
zrotation = (atof(com_token) + 90) * (M_PI / 180.0);
|
||||
}
|
||||
|
||||
void Option_ScaleUp (void)
|
||||
{
|
||||
scale_up = atof (SC_GetToken (false));
|
||||
scale_up = atof (Com_GetToken (false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1977,9 +1977,9 @@ int Cmd_Sequence( void )
|
|||
int start = 0;
|
||||
int end = MAXSTUDIOANIMATIONS - 1;
|
||||
|
||||
if(!SC_GetToken(false)) return 0;
|
||||
if(!Com_GetToken(false)) return 0;
|
||||
|
||||
strncpy( sequence[numseq].name, SC_Token(), sizeof(sequence[numseq].name));
|
||||
strncpy( sequence[numseq].name, com_token, sizeof(sequence[numseq].name));
|
||||
|
||||
VectorCopy( defaultadjust, adjust );
|
||||
scale_up = default_scale;
|
||||
|
@ -1995,69 +1995,69 @@ int Cmd_Sequence( void )
|
|||
{
|
||||
if (depth > 0)
|
||||
{
|
||||
if(!SC_GetToken(true)) break;
|
||||
if(!Com_GetToken(true)) break;
|
||||
}
|
||||
else if(!SC_TryToken()) break;
|
||||
else if(!Com_TryToken()) break;
|
||||
|
||||
if (SC_MatchToken( "{" )) depth++;
|
||||
else if (SC_MatchToken( "}" )) depth--;
|
||||
else if (SC_MatchToken( "event" )) depth -= Option_Event( &sequence[numseq] );
|
||||
else if (SC_MatchToken( "pivot" )) Option_AddPivot( &sequence[numseq] );
|
||||
else if (SC_MatchToken( "fps" )) Option_Fps( &sequence[numseq] );
|
||||
else if (SC_MatchToken( "origin" )) Option_Origin();
|
||||
else if (SC_MatchToken( "rotate" )) Option_Rotate();
|
||||
else if (SC_MatchToken( "scale" )) Option_ScaleUp();
|
||||
else if (SC_MatchToken( "loop" )) sequence[numseq].flags |= STUDIO_LOOPING;
|
||||
else if (SC_MatchToken( "frame" ))
|
||||
if (Com_MatchToken( "{" )) depth++;
|
||||
else if (Com_MatchToken( "}" )) depth--;
|
||||
else if (Com_MatchToken( "event" )) depth -= Option_Event( &sequence[numseq] );
|
||||
else if (Com_MatchToken( "pivot" )) Option_AddPivot( &sequence[numseq] );
|
||||
else if (Com_MatchToken( "fps" )) Option_Fps( &sequence[numseq] );
|
||||
else if (Com_MatchToken( "origin" )) Option_Origin();
|
||||
else if (Com_MatchToken( "rotate" )) Option_Rotate();
|
||||
else if (Com_MatchToken( "scale" )) Option_ScaleUp();
|
||||
else if (Com_MatchToken( "loop" )) sequence[numseq].flags |= STUDIO_LOOPING;
|
||||
else if (Com_MatchToken( "frame" ))
|
||||
{
|
||||
start = atoi(SC_GetToken( false ));
|
||||
end = atoi(SC_GetToken( false ));
|
||||
start = atoi(Com_GetToken( false ));
|
||||
end = atoi(Com_GetToken( false ));
|
||||
}
|
||||
else if (SC_MatchToken( "blend" ))
|
||||
else if (Com_MatchToken( "blend" ))
|
||||
{
|
||||
sequence[numseq].blendtype[0] = lookupControl(SC_GetToken( false ));
|
||||
sequence[numseq].blendstart[0] = atof(SC_GetToken( false ));
|
||||
sequence[numseq].blendend[0] = atof(SC_GetToken( false ));
|
||||
sequence[numseq].blendtype[0] = lookupControl(Com_GetToken( false ));
|
||||
sequence[numseq].blendstart[0] = atof(Com_GetToken( false ));
|
||||
sequence[numseq].blendend[0] = atof(Com_GetToken( false ));
|
||||
}
|
||||
else if (SC_MatchToken( "node" ))
|
||||
else if (Com_MatchToken( "node" ))
|
||||
{
|
||||
sequence[numseq].entrynode = sequence[numseq].exitnode = atoi(SC_GetToken( false ));
|
||||
sequence[numseq].entrynode = sequence[numseq].exitnode = atoi(Com_GetToken( false ));
|
||||
}
|
||||
else if (SC_MatchToken( "transition" ))
|
||||
else if (Com_MatchToken( "transition" ))
|
||||
{
|
||||
sequence[numseq].entrynode = atoi(SC_GetToken( false ));
|
||||
sequence[numseq].exitnode = atoi(SC_GetToken( false ));
|
||||
sequence[numseq].entrynode = atoi(Com_GetToken( false ));
|
||||
sequence[numseq].exitnode = atoi(Com_GetToken( false ));
|
||||
}
|
||||
else if (SC_MatchToken( "rtransition" ))
|
||||
else if (Com_MatchToken( "rtransition" ))
|
||||
{
|
||||
sequence[numseq].entrynode = atoi(SC_GetToken( false ));
|
||||
sequence[numseq].exitnode = atoi(SC_GetToken( false ));
|
||||
sequence[numseq].entrynode = atoi(Com_GetToken( false ));
|
||||
sequence[numseq].exitnode = atoi(Com_GetToken( false ));
|
||||
sequence[numseq].nodeflags |= 1;
|
||||
}
|
||||
else if (lookupControl( SC_Token()) != -1)
|
||||
else if (lookupControl( com_token) != -1)
|
||||
{
|
||||
sequence[numseq].motiontype |= lookupControl( SC_Token());
|
||||
sequence[numseq].motiontype |= lookupControl( com_token);
|
||||
}
|
||||
else if (SC_MatchToken( "animation" ))
|
||||
else if (Com_MatchToken( "animation" ))
|
||||
{
|
||||
strncpy( smdfilename[numblends], SC_GetToken( false ), sizeof(smdfilename[numblends]));
|
||||
strncpy( smdfilename[numblends], Com_GetToken( false ), sizeof(smdfilename[numblends]));
|
||||
numblends++;
|
||||
}
|
||||
else if (i = lookupActivity( SC_Token()))
|
||||
else if (i = lookupActivity( com_token))
|
||||
{
|
||||
sequence[numseq].activity = i;
|
||||
sequence[numseq].actweight = 1;//default weight
|
||||
if(SC_TryToken())
|
||||
if(Com_TryToken())
|
||||
{
|
||||
//make sure what is really actweight
|
||||
if(!SC_MatchToken("{") && !SC_MatchToken("}") && strlen(SC_Token()) < 3 && atoi(SC_Token()) <= 100)
|
||||
sequence[numseq].actweight = atoi(SC_Token());
|
||||
else SC_FreeToken();//release token
|
||||
// make sure what is really actweight
|
||||
if(!Com_MatchToken("{") && !Com_MatchToken("}") && strlen(com_token) < 3 && atoi(com_token) <= 100)
|
||||
sequence[numseq].actweight = atoi(com_token);
|
||||
else Com_FreeToken(); // release token
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
strncpy( smdfilename[numblends], SC_Token(), sizeof(smdfilename[numblends]));
|
||||
strncpy( smdfilename[numblends], com_token, sizeof(smdfilename[numblends]));
|
||||
numblends++;
|
||||
}
|
||||
}
|
||||
|
@ -2092,9 +2092,9 @@ syntax: $root "pivotname"
|
|||
*/
|
||||
int Cmd_Root (void)
|
||||
{
|
||||
if (SC_GetToken(false))
|
||||
if (Com_GetToken(false))
|
||||
{
|
||||
strncpy( pivotname[0], SC_Token(), sizeof(pivotname));
|
||||
strncpy( pivotname[0], com_token, sizeof(pivotname));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
@ -2109,12 +2109,12 @@ syntax: $pivot (<index>) ("pivotname")
|
|||
*/
|
||||
int Cmd_Pivot (void)
|
||||
{
|
||||
if (SC_GetToken (false))
|
||||
if (Com_GetToken (false))
|
||||
{
|
||||
int index = atoi(SC_Token());
|
||||
if (SC_GetToken(false))
|
||||
int index = atoi(com_token);
|
||||
if (Com_GetToken(false))
|
||||
{
|
||||
strncpy( pivotname[index], SC_Token(), sizeof(pivotname[index]));
|
||||
strncpy( pivotname[index], com_token, sizeof(pivotname[index]));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -2130,25 +2130,25 @@ syntax: $controller "mouth"|<number> ("name") <type> <start> <end>
|
|||
*/
|
||||
int Cmd_Controller (void)
|
||||
{
|
||||
if (SC_GetToken (false))
|
||||
if (Com_GetToken (false))
|
||||
{
|
||||
//mouth is hardcoded at four controller
|
||||
if (SC_MatchToken( "mouth" )) bonecontroller[numbonecontrollers].index = 4;
|
||||
else bonecontroller[numbonecontrollers].index = atoi(SC_Token());
|
||||
if (Com_MatchToken( "mouth" )) bonecontroller[numbonecontrollers].index = 4;
|
||||
else bonecontroller[numbonecontrollers].index = atoi(com_token);
|
||||
|
||||
if (SC_GetToken(false))
|
||||
if (Com_GetToken(false))
|
||||
{
|
||||
strncpy( bonecontroller[numbonecontrollers].name, SC_Token(), sizeof(bonecontroller[numbonecontrollers].name));
|
||||
strncpy( bonecontroller[numbonecontrollers].name, com_token, sizeof(bonecontroller[numbonecontrollers].name));
|
||||
|
||||
SC_GetToken(false);
|
||||
if ((bonecontroller[numbonecontrollers].type = lookupControl(SC_Token())) == -1)
|
||||
Com_GetToken(false);
|
||||
if ((bonecontroller[numbonecontrollers].type = lookupControl(com_token)) == -1)
|
||||
{
|
||||
MsgWarn("Cmd_Controller: unknown bonecontroller type '%s'\n", SC_Token() );
|
||||
MsgWarn("Cmd_Controller: unknown bonecontroller type '%s'\n", com_token );
|
||||
return 0;
|
||||
}
|
||||
|
||||
bonecontroller[numbonecontrollers].start = atof(SC_GetToken(false));
|
||||
bonecontroller[numbonecontrollers].end = atof(SC_GetToken(false));
|
||||
bonecontroller[numbonecontrollers].start = atof(Com_GetToken(false));
|
||||
bonecontroller[numbonecontrollers].end = atof(Com_GetToken(false));
|
||||
|
||||
if (bonecontroller[numbonecontrollers].type & (STUDIO_XR | STUDIO_YR | STUDIO_ZR))
|
||||
{
|
||||
|
@ -2170,12 +2170,12 @@ syntax: $bbox <mins0> <mins1> <mins2> <maxs0> <maxs1> <maxs2>
|
|||
*/
|
||||
void Cmd_BBox (void)
|
||||
{
|
||||
bbox[0][0] = atof(SC_GetToken(false));
|
||||
bbox[0][1] = atof(SC_GetToken(false));
|
||||
bbox[0][2] = atof(SC_GetToken(false));
|
||||
bbox[1][0] = atof(SC_GetToken(false));
|
||||
bbox[1][1] = atof(SC_GetToken(false));
|
||||
bbox[1][2] = atof(SC_GetToken(false));
|
||||
bbox[0][0] = atof(Com_GetToken(false));
|
||||
bbox[0][1] = atof(Com_GetToken(false));
|
||||
bbox[0][2] = atof(Com_GetToken(false));
|
||||
bbox[1][0] = atof(Com_GetToken(false));
|
||||
bbox[1][1] = atof(Com_GetToken(false));
|
||||
bbox[1][2] = atof(Com_GetToken(false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2187,12 +2187,12 @@ syntax: $cbox <mins0> <mins1> <mins2> <maxs0> <maxs1> <maxs2>
|
|||
*/
|
||||
void Cmd_CBox (void)
|
||||
{
|
||||
cbox[0][0] = atof(SC_GetToken(false));
|
||||
cbox[0][1] = atof(SC_GetToken(false));
|
||||
cbox[0][2] = atof(SC_GetToken(false));
|
||||
cbox[1][0] = atof(SC_GetToken(false));
|
||||
cbox[1][1] = atof(SC_GetToken(false));
|
||||
cbox[1][2] = atof(SC_GetToken(false));
|
||||
cbox[0][0] = atof(Com_GetToken(false));
|
||||
cbox[0][1] = atof(Com_GetToken(false));
|
||||
cbox[0][2] = atof(Com_GetToken(false));
|
||||
cbox[1][0] = atof(Com_GetToken(false));
|
||||
cbox[1][1] = atof(Com_GetToken(false));
|
||||
cbox[1][2] = atof(Com_GetToken(false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2204,7 +2204,7 @@ syntax: $mirrorbone "name"
|
|||
*/
|
||||
void Cmd_Mirror ( void )
|
||||
{
|
||||
strncpy( mirrored[nummirrored], SC_GetToken(false), sizeof(mirrored[nummirrored]));
|
||||
strncpy( mirrored[nummirrored], Com_GetToken(false), sizeof(mirrored[nummirrored]));
|
||||
nummirrored++;
|
||||
}
|
||||
|
||||
|
@ -2217,7 +2217,7 @@ syntax: $gamma <value>
|
|||
*/
|
||||
void Cmd_Gamma ( void )
|
||||
{
|
||||
gamma = atof(SC_GetToken(false));
|
||||
gamma = atof(Com_GetToken(false));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -2245,19 +2245,19 @@ int Cmd_TextureGroup( void )
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!SC_GetToken(false)) return 0;
|
||||
if (!Com_GetToken(false)) return 0;
|
||||
if (numskinref == 0) numskinref = numtextures;
|
||||
|
||||
while (1)
|
||||
{
|
||||
if(!SC_GetToken(true))
|
||||
if(!Com_GetToken(true))
|
||||
{
|
||||
if (depth)MsgWarn("missing }\n");
|
||||
break;
|
||||
}
|
||||
|
||||
if (SC_MatchToken( "{" )) depth++;
|
||||
else if (SC_MatchToken( "}" ))
|
||||
if (Com_MatchToken( "{" )) depth++;
|
||||
else if (Com_MatchToken( "}" ))
|
||||
{
|
||||
depth--;
|
||||
if (depth == 0) break;
|
||||
|
@ -2266,7 +2266,7 @@ int Cmd_TextureGroup( void )
|
|||
}
|
||||
else if (depth == 2)
|
||||
{
|
||||
i = lookup_texture( SC_Token());
|
||||
i = lookup_texture( com_token);
|
||||
texturegroup[numtexturegroups][group][index] = i;
|
||||
if (group != 0) texture[i].parent = texturegroup[numtexturegroups][0][index];
|
||||
index++;
|
||||
|
@ -2288,8 +2288,8 @@ syntax: $hitgroup <index> <name>
|
|||
*/
|
||||
int Cmd_Hitgroup( void )
|
||||
{
|
||||
hitgroup[numhitgroups].group = atoi(SC_GetToken(false));
|
||||
strncpy( hitgroup[numhitgroups].name, SC_GetToken(false), sizeof(hitgroup[numhitgroups].name));
|
||||
hitgroup[numhitgroups].group = atoi(Com_GetToken(false));
|
||||
strncpy( hitgroup[numhitgroups].name, Com_GetToken(false), sizeof(hitgroup[numhitgroups].name));
|
||||
numhitgroups++;
|
||||
|
||||
return 0;
|
||||
|
@ -2304,14 +2304,14 @@ syntax: $hbox <index> <name> <mins0> <mins1> <mins2> <maxs0> <maxs1> <maxs2>
|
|||
*/
|
||||
int Cmd_Hitbox( void )
|
||||
{
|
||||
hitbox[numhitboxes].group = atoi(SC_GetToken(false));
|
||||
strncpy( hitbox[numhitboxes].name, SC_GetToken(false), sizeof(hitbox[numhitboxes].name));
|
||||
hitbox[numhitboxes].bmin[0] = atof( SC_GetToken(false));
|
||||
hitbox[numhitboxes].bmin[1] = atof(SC_GetToken(false));
|
||||
hitbox[numhitboxes].bmin[2] = atof(SC_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[0] = atof(SC_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[1] = atof(SC_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[2] = atof(SC_GetToken(false));
|
||||
hitbox[numhitboxes].group = atoi(Com_GetToken(false));
|
||||
strncpy( hitbox[numhitboxes].name, Com_GetToken(false), sizeof(hitbox[numhitboxes].name));
|
||||
hitbox[numhitboxes].bmin[0] = atof( Com_GetToken(false));
|
||||
hitbox[numhitboxes].bmin[1] = atof(Com_GetToken(false));
|
||||
hitbox[numhitboxes].bmin[2] = atof(Com_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[0] = atof(Com_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[1] = atof(Com_GetToken(false));
|
||||
hitbox[numhitboxes].bmax[2] = atof(Com_GetToken(false));
|
||||
numhitboxes++;
|
||||
|
||||
return 0;
|
||||
|
@ -2327,16 +2327,16 @@ syntax: $attachment <index> <bonename> <x> <y> <z> (old stuff)
|
|||
int Cmd_Attachment( void )
|
||||
{
|
||||
// index
|
||||
attachment[numattachments].index = atoi(SC_GetToken(false));
|
||||
attachment[numattachments].index = atoi(Com_GetToken(false));
|
||||
// bone name
|
||||
strncpy( attachment[numattachments].bonename, SC_GetToken(false), sizeof(attachment[numattachments].bonename));
|
||||
strncpy( attachment[numattachments].bonename, Com_GetToken(false), sizeof(attachment[numattachments].bonename));
|
||||
// position
|
||||
attachment[numattachments].org[0] = atof(SC_GetToken(false));
|
||||
attachment[numattachments].org[1] = atof(SC_GetToken(false));
|
||||
attachment[numattachments].org[2] = atof(SC_GetToken(false));
|
||||
attachment[numattachments].org[0] = atof(Com_GetToken(false));
|
||||
attachment[numattachments].org[1] = atof(Com_GetToken(false));
|
||||
attachment[numattachments].org[2] = atof(Com_GetToken(false));
|
||||
|
||||
//skip old stuff
|
||||
while(SC_TryToken());
|
||||
while(Com_TryToken());
|
||||
|
||||
numattachments++;
|
||||
return 0;
|
||||
|
@ -2351,8 +2351,8 @@ syntax: $renamebone <oldname> <newname>
|
|||
*/
|
||||
void Cmd_Renamebone( void )
|
||||
{
|
||||
strcpy( renamedbone[numrenamedbones].from, SC_GetToken(false));
|
||||
strcpy( renamedbone[numrenamedbones].to, SC_GetToken(false));
|
||||
strcpy( renamedbone[numrenamedbones].from, Com_GetToken(false));
|
||||
strcpy( renamedbone[numrenamedbones].to, Com_GetToken(false));
|
||||
numrenamedbones++;
|
||||
}
|
||||
|
||||
|
@ -2368,22 +2368,22 @@ void Cmd_TexRenderMode( void )
|
|||
{
|
||||
char tex_name[64];
|
||||
|
||||
strcpy(tex_name, SC_GetToken(false));
|
||||
SC_GetToken(false);
|
||||
strcpy(tex_name, Com_GetToken(false));
|
||||
Com_GetToken(false);
|
||||
|
||||
if(SC_MatchToken( "additive" ))
|
||||
if(Com_MatchToken( "additive" ))
|
||||
{
|
||||
texture[lookup_texture(tex_name)].flags |= STUDIO_NF_ADDITIVE;
|
||||
}
|
||||
else if(SC_MatchToken( "masked" ))
|
||||
else if(Com_MatchToken( "masked" ))
|
||||
{
|
||||
texture[lookup_texture(tex_name)].flags |= STUDIO_NF_TRANSPARENT;
|
||||
}
|
||||
else if(SC_MatchToken( "blended" ))
|
||||
else if(Com_MatchToken( "blended" ))
|
||||
{
|
||||
texture[lookup_texture(tex_name)].flags |= STUDIO_NF_BLENDED;
|
||||
}
|
||||
else MsgWarn("Cmd_TexRenderMode: texture '%s' have unknown render mode '%s'!\n", tex_name, SC_Token());
|
||||
else MsgWarn("Cmd_TexRenderMode: texture '%s' have unknown render mode '%s'!\n", tex_name, com_token);
|
||||
|
||||
}
|
||||
|
||||
|
@ -2396,8 +2396,8 @@ syntax: $replacetexture "oldname.bmp" "newname.bmp"
|
|||
*/
|
||||
void Cmd_Replace( void )
|
||||
{
|
||||
strcpy ( sourcetexture[numrep], SC_GetToken(false));
|
||||
strcpy ( defaulttexture[numrep], SC_GetToken(false));
|
||||
strcpy ( sourcetexture[numrep], Com_GetToken(false));
|
||||
strcpy ( defaulttexture[numrep], Com_GetToken(false));
|
||||
numrep++;
|
||||
}
|
||||
|
||||
|
@ -2413,7 +2413,7 @@ void Cmd_CdSet( void )
|
|||
if(!cdset)
|
||||
{
|
||||
cdset = true;
|
||||
FS_AddGameHierarchy( SC_GetToken (false));
|
||||
FS_AddGameHierarchy( Com_GetToken (false));
|
||||
}
|
||||
else Msg("Warning: $cd already set\n");
|
||||
}
|
||||
|
@ -2430,7 +2430,7 @@ void Cmd_CdTextureSet( void )
|
|||
if(cdtextureset < 16)
|
||||
{
|
||||
cdtextureset++;
|
||||
FS_AddGameHierarchy( SC_GetToken (false));
|
||||
FS_AddGameHierarchy( Com_GetToken (false));
|
||||
}
|
||||
else Msg("Warning: $cdtexture already set\n");
|
||||
}
|
||||
|
@ -2465,8 +2465,8 @@ syntax: "blabla"
|
|||
*/
|
||||
void Cmd_StudioUnknown( void )
|
||||
{
|
||||
MsgWarn("Cmd_StudioUnknown: skip command \"%s\"\n", SC_Token());
|
||||
while(SC_TryToken());
|
||||
MsgWarn("Cmd_StudioUnknown: skip command \"%s\"\n", com_token);
|
||||
while(Com_TryToken());
|
||||
}
|
||||
|
||||
bool ParseModelScript (void)
|
||||
|
@ -2475,39 +2475,39 @@ bool ParseModelScript (void)
|
|||
|
||||
while (1)
|
||||
{
|
||||
if(!SC_GetToken (true)) break;
|
||||
if(!Com_GetToken (true)) break;
|
||||
|
||||
if (SC_MatchToken("$modelname")) Cmd_Modelname ();
|
||||
else if (SC_MatchToken("$cd")) Cmd_CdSet();
|
||||
else if (SC_MatchToken("$cdtexture")) Cmd_CdTextureSet();
|
||||
else if (SC_MatchToken("$scale")) Cmd_ScaleUp ();
|
||||
else if (SC_MatchToken("$rotate")) Cmd_Rotate();
|
||||
else if (SC_MatchToken("$root")) Cmd_Root ();
|
||||
else if (SC_MatchToken("$pivot")) Cmd_Pivot ();
|
||||
else if (SC_MatchToken("$controller")) Cmd_Controller ();
|
||||
else if (SC_MatchToken("$body")) Cmd_Body();
|
||||
else if (SC_MatchToken("$bodygroup")) Cmd_Bodygroup();
|
||||
else if (SC_MatchToken("$sequence")) Cmd_Sequence ();
|
||||
else if (SC_MatchToken("$eyeposition")) Cmd_Eyeposition ();
|
||||
else if (SC_MatchToken("$origin")) Cmd_Origin ();
|
||||
else if (SC_MatchToken("$bbox")) Cmd_BBox ();
|
||||
else if (SC_MatchToken("$cbox")) Cmd_CBox ();
|
||||
else if (SC_MatchToken("$mirrorbone")) Cmd_Mirror ();
|
||||
else if (SC_MatchToken("$gamma")) Cmd_Gamma ();
|
||||
else if (SC_MatchToken("$texturegroup")) Cmd_TextureGroup ();
|
||||
else if (SC_MatchToken("$hgroup")) Cmd_Hitgroup ();
|
||||
else if (SC_MatchToken("$hbox")) Cmd_Hitbox ();
|
||||
else if (SC_MatchToken("$attachment")) Cmd_Attachment ();
|
||||
else if (SC_MatchToken("$cliptotextures")) clip_texcoords = 1;
|
||||
else if (SC_MatchToken("$renamebone")) Cmd_Renamebone ();
|
||||
else if (SC_MatchToken("$texrendermode")) Cmd_TexRenderMode();
|
||||
else if (SC_MatchToken("$replacetexture")) Cmd_Replace();
|
||||
else if (SC_MatchToken("$spritename"))
|
||||
if (Com_MatchToken("$modelname")) Cmd_Modelname ();
|
||||
else if (Com_MatchToken("$cd")) Cmd_CdSet();
|
||||
else if (Com_MatchToken("$cdtexture")) Cmd_CdTextureSet();
|
||||
else if (Com_MatchToken("$scale")) Cmd_ScaleUp ();
|
||||
else if (Com_MatchToken("$rotate")) Cmd_Rotate();
|
||||
else if (Com_MatchToken("$root")) Cmd_Root ();
|
||||
else if (Com_MatchToken("$pivot")) Cmd_Pivot ();
|
||||
else if (Com_MatchToken("$controller")) Cmd_Controller ();
|
||||
else if (Com_MatchToken("$body")) Cmd_Body();
|
||||
else if (Com_MatchToken("$bodygroup")) Cmd_Bodygroup();
|
||||
else if (Com_MatchToken("$sequence")) Cmd_Sequence ();
|
||||
else if (Com_MatchToken("$eyeposition")) Cmd_Eyeposition ();
|
||||
else if (Com_MatchToken("$origin")) Cmd_Origin ();
|
||||
else if (Com_MatchToken("$bbox")) Cmd_BBox ();
|
||||
else if (Com_MatchToken("$cbox")) Cmd_CBox ();
|
||||
else if (Com_MatchToken("$mirrorbone")) Cmd_Mirror ();
|
||||
else if (Com_MatchToken("$gamma")) Cmd_Gamma ();
|
||||
else if (Com_MatchToken("$texturegroup")) Cmd_TextureGroup ();
|
||||
else if (Com_MatchToken("$hgroup")) Cmd_Hitgroup ();
|
||||
else if (Com_MatchToken("$hbox")) Cmd_Hitbox ();
|
||||
else if (Com_MatchToken("$attachment")) Cmd_Attachment ();
|
||||
else if (Com_MatchToken("$cliptotextures")) clip_texcoords = 1;
|
||||
else if (Com_MatchToken("$renamebone")) Cmd_Renamebone ();
|
||||
else if (Com_MatchToken("$texrendermode")) Cmd_TexRenderMode();
|
||||
else if (Com_MatchToken("$replacetexture")) Cmd_Replace();
|
||||
else if (Com_MatchToken("$spritename"))
|
||||
{
|
||||
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
|
||||
return false;
|
||||
}
|
||||
else if (SC_MatchToken("$frame"))
|
||||
else if (Com_MatchToken("$frame"))
|
||||
{
|
||||
Msg("%s probably spritegen qc.script, skipping...\n", gs_mapname );
|
||||
return false;
|
||||
|
@ -2549,7 +2549,7 @@ bool CompileCurrentModel( const char *name )
|
|||
|
||||
if(name) strcpy( gs_mapname, name );
|
||||
FS_DefaultExtension( gs_mapname, ".qc" );
|
||||
load = FS_LoadScript( gs_mapname, NULL, 0 );
|
||||
load = Com_LoadScript( gs_mapname, NULL, 0 );
|
||||
|
||||
if(load)
|
||||
{
|
||||
|
|
|
@ -10,261 +10,12 @@
|
|||
#include "qcclib.h"
|
||||
#include "blankframe.h"
|
||||
|
||||
|
||||
int com_argc;
|
||||
char **com_argv;
|
||||
char gs_basedir[ MAX_SYSPATH ]; // initial dir before loading gameinfo.txt (used for compilers too)
|
||||
char gs_mapname[ MAX_QPATH ]; // used for compilers only
|
||||
|
||||
/*
|
||||
================
|
||||
CheckParm
|
||||
|
||||
Returns the position (1 to argc-1) in the program's argument list
|
||||
where the given parameter apears, or 0 if not present
|
||||
================
|
||||
*/
|
||||
int FS_CheckParm (const char *parm)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < com_argc; i++ )
|
||||
{
|
||||
// NEXTSTEP sometimes clears appkit vars.
|
||||
if (!com_argv[i]) continue;
|
||||
if (!strcmp (parm, com_argv[i])) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool FS_GetParmFromCmdLine( char *parm, char *out )
|
||||
{
|
||||
int argc = FS_CheckParm( parm );
|
||||
|
||||
if(!argc) return false;
|
||||
if(!out) return false;
|
||||
if(!com_argv[argc + 1]) return false;
|
||||
|
||||
strcpy( out, com_argv[argc+1] );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// INFOSTRING STUFF
|
||||
//=======================================================================
|
||||
/*
|
||||
===============
|
||||
Info_Print
|
||||
|
||||
printing current key-value pair
|
||||
===============
|
||||
*/
|
||||
void Info_Print (char *s)
|
||||
{
|
||||
char key[512];
|
||||
char value[512];
|
||||
char *o;
|
||||
int l;
|
||||
|
||||
if (*s == '\\') s++;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
o = key;
|
||||
while (*s && *s != '\\') *o++ = *s++;
|
||||
|
||||
l = o - key;
|
||||
if (l < 20)
|
||||
{
|
||||
memset (o, ' ', 20-l);
|
||||
key[20] = 0;
|
||||
}
|
||||
else *o = 0;
|
||||
Msg ("%s", key);
|
||||
|
||||
if (!*s)
|
||||
{
|
||||
Msg ("MISSING VALUE\n");
|
||||
return;
|
||||
}
|
||||
|
||||
o = value;
|
||||
s++;
|
||||
while (*s && *s != '\\') *o++ = *s++;
|
||||
*o = 0;
|
||||
|
||||
if (*s) s++;
|
||||
Msg ("%s\n", value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Info_ValueForKey
|
||||
|
||||
Searches the string for the given
|
||||
key and returns the associated value, or an empty string.
|
||||
===============
|
||||
*/
|
||||
char *Info_ValueForKey (char *s, char *key)
|
||||
{
|
||||
char pkey[512];
|
||||
static char value[2][512]; // use two buffers so compares work without stomping on each other
|
||||
static int valueindex;
|
||||
char *o;
|
||||
|
||||
valueindex ^= 1;
|
||||
if (*s == '\\') s++;
|
||||
while (1)
|
||||
{
|
||||
o = pkey;
|
||||
while (*s != '\\')
|
||||
{
|
||||
if (!*s) return "";
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
s++;
|
||||
|
||||
o = value[valueindex];
|
||||
|
||||
while (*s != '\\' && *s)
|
||||
{
|
||||
if (!*s) return "";
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey) ) return value[valueindex];
|
||||
if (!*s) return "";
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void Info_RemoveKey (char *s, char *key)
|
||||
{
|
||||
char *start;
|
||||
char pkey[512];
|
||||
char value[512];
|
||||
char *o;
|
||||
|
||||
if (strstr (key, "\\")) return;
|
||||
|
||||
while (1)
|
||||
{
|
||||
start = s;
|
||||
if (*s == '\\') s++;
|
||||
o = pkey;
|
||||
while (*s != '\\')
|
||||
{
|
||||
if (!*s) return;
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
s++;
|
||||
|
||||
o = value;
|
||||
while (*s != '\\' && *s)
|
||||
{
|
||||
if (!*s) return;
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey) )
|
||||
{
|
||||
strcpy (start, s); // remove this part
|
||||
return;
|
||||
}
|
||||
if (!*s) return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Info_Validate
|
||||
|
||||
Some characters are illegal in info strings because they
|
||||
can mess up the server's parsing
|
||||
==================
|
||||
*/
|
||||
bool Info_Validate (char *s)
|
||||
{
|
||||
if (strstr (s, "\"")) return false;
|
||||
if (strstr (s, ";")) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Info_SetValueForKey (char *s, char *key, char *value)
|
||||
{
|
||||
char newi[MAX_INFO_STRING], *v;
|
||||
int c, maxsize = MAX_INFO_STRING;
|
||||
|
||||
if (strstr (key, "\\") || strstr (value, "\\") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a \\\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr (key, ";") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a semicolon\n");
|
||||
return;
|
||||
}
|
||||
if (strstr (key, "\"") || strstr (value, "\"") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a \"\n");
|
||||
return;
|
||||
}
|
||||
if (strlen(key) > MAX_INFO_KEY - 1 || strlen(value) > MAX_INFO_KEY-1)
|
||||
{
|
||||
Msg ("Keys and values must be < 64 characters.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Info_RemoveKey (s, key);
|
||||
if (!value || !strlen(value)) return;
|
||||
sprintf (newi, "\\%s\\%s", key, value);
|
||||
|
||||
if (strlen(newi) + strlen(s) > maxsize)
|
||||
{
|
||||
Msg ("Info string length exceeded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// only copy ascii values
|
||||
s += strlen(s);
|
||||
v = newi;
|
||||
while (*v)
|
||||
{
|
||||
c = *v++;
|
||||
c &= 127; // strip high bits
|
||||
if (c >= 32 && c < 127) *s++ = c;
|
||||
}
|
||||
*s = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
EXTERNAL INFOSTRING STUFF INTERFACE
|
||||
=============================================================================
|
||||
*/
|
||||
infostring_api_t Info_GetAPI( void )
|
||||
{
|
||||
static infostring_api_t info;
|
||||
|
||||
info.api_size = sizeof(infostring_api_t);
|
||||
|
||||
info.Print = Info_Print;
|
||||
info.Validate = Info_Validate;
|
||||
info.RemoveKey = Info_RemoveKey;
|
||||
info.ValueForKey = Info_ValueForKey;
|
||||
info.SetValueForKey = Info_SetValueForKey;
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
unsigned __int64 __g_ProfilerStart;
|
||||
unsigned __int64 __g_ProfilerEnd;
|
||||
unsigned __int64 __g_ProfilerEnd2;
|
||||
|
@ -327,6 +78,33 @@ void Profile_Time( void )
|
|||
else MsgWarn("--- Profiler not supported ---\n");
|
||||
}
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.BMP image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char id[2]; //bmfh.bfType
|
||||
dword fileSize; //bmfh.bfSize
|
||||
dword reserved0; //bmfh.bfReserved1 + bmfh.bfReserved2
|
||||
dword bitmapDataOffset; //bmfh.bfOffBits
|
||||
dword bitmapHeaderSize; //bmih.biSize
|
||||
dword width; //bmih.biWidth
|
||||
dword height; //bmih.biHeight
|
||||
word planes; //bmih.biPlanes
|
||||
word bitsPerPixel; //bmih.biBitCount
|
||||
dword compression; //bmih.biCompression
|
||||
dword bitmapDataSize; //bmih.biSizeImage
|
||||
dword hRes; //bmih.biXPelsPerMeter
|
||||
dword vRes; //bmih.biYPelsPerMeter
|
||||
dword colors; //bmih.biClrUsed
|
||||
dword importantColors; //bmih.biClrImportant
|
||||
byte palette[256][4]; //RGBQUAD palette
|
||||
} bmp_t;
|
||||
|
||||
/*
|
||||
================
|
||||
ReadBMP
|
||||
|
@ -465,30 +243,4 @@ byte *ReadBMP (char *filename, byte **palette, int *width, int *height)
|
|||
if( buf ) Free( buf );
|
||||
|
||||
return pbBmpBits;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
COMPILERS PACKAGE INTERFACE
|
||||
=============================================================================
|
||||
*/
|
||||
compilers_api_t Comp_GetAPI( void )
|
||||
{
|
||||
static compilers_api_t cp;
|
||||
|
||||
cp.api_size = sizeof(compilers_api_t);
|
||||
|
||||
cp.Studio = CompileStudioModel;
|
||||
cp.Sprite = CompileSpriteModel;
|
||||
cp.Image = ConvertImagePixels;
|
||||
cp.PrepareBSP = PrepareBSPModel;
|
||||
cp.BSP = CompileBSPModel;
|
||||
cp.PrepareDAT = PrepareDATProgs;
|
||||
cp.DAT = CompileDATProgs;
|
||||
cp.DecryptDAT = PR_decode;
|
||||
cp.PrepareROQ = PrepareROQVideo;
|
||||
cp.ROQ = MakeROQ;
|
||||
|
||||
return cp;
|
||||
}
|
|
@ -7,6 +7,19 @@
|
|||
|
||||
#include <time.h>
|
||||
|
||||
// bsplib compile flags
|
||||
#define BSP_ONLYENTS 0x01
|
||||
#define BSP_ONLYVIS 0x02
|
||||
#define BSP_ONLYRAD 0x04
|
||||
#define BSP_FULLCOMPILE 0x08
|
||||
|
||||
// qcclib compile flags
|
||||
#define QCC_PROGDEFS 0x01
|
||||
#define QCC_OPT_LEVEL_0 0x02
|
||||
#define QCC_OPT_LEVEL_1 0x04
|
||||
#define QCC_OPT_LEVEL_2 0x08
|
||||
#define QCC_OPT_LEVEL_3 0x10
|
||||
|
||||
#define ALIGN( a ) a = (byte *)((int)((byte *)a + 3) & ~ 3)
|
||||
|
||||
extern unsigned __int64 __g_ProfilerStart;
|
||||
|
@ -17,6 +30,8 @@ extern unsigned __int64 __g_ProfilerTotalTicks;
|
|||
extern double __g_ProfilerTotalMsec;
|
||||
extern int com_argc;
|
||||
extern char **com_argv;
|
||||
extern byte *basepool;
|
||||
extern byte *zonepool;
|
||||
|
||||
#define Profile_Start()\
|
||||
{\
|
||||
|
@ -53,98 +68,13 @@ void Profile_Store( void );
|
|||
void Profile_Time( void ); // total profile time
|
||||
#define Profile_Results( name ) _Profile_Results( #name )
|
||||
|
||||
#define numthreads std.get_numthreads()
|
||||
#define ThreadLock std.thread_lock
|
||||
#define ThreadUnlock std.thread_unlock
|
||||
#define RunThreadsOnIndividual std.create_thread
|
||||
|
||||
//=====================================
|
||||
// memory manager funcs
|
||||
//=====================================
|
||||
#define Mem_Alloc(pool, size) std.malloc(pool, size, __FILE__, __LINE__)
|
||||
#define Mem_Realloc(pool, ptr, size) std.realloc(pool, ptr, size, __FILE__, __LINE__)
|
||||
#define Mem_Move(pool, ptr, data, size) std.move(pool, ptr, data, size, __FILE__, __LINE__)
|
||||
#define Mem_Free(mem) std.free(mem, __FILE__, __LINE__)
|
||||
#define Mem_AllocPool(name) std.mallocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) std.freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) std.clearpool(pool, __FILE__, __LINE__)
|
||||
#define Mem_Copy(dest, src, size ) std.memcpy(dest, src, size, __FILE__, __LINE__)
|
||||
|
||||
//=====================================
|
||||
// parsing manager funcs
|
||||
//=====================================
|
||||
#define SC_ParseToken std.Script.ParseToken
|
||||
#define SC_ParseWord std.Script.ParseWord
|
||||
#define SC_Token() std.Script.Token
|
||||
#define SC_Filter std.Script.FilterToken
|
||||
#define FS_LoadScript std.Script.Load
|
||||
#define FS_AddScript std.Script.Include
|
||||
#define FS_ResetScript std.Script.Reset
|
||||
#define SC_GetToken std.Script.GetToken
|
||||
#define SC_TryToken std.Script.TryToken
|
||||
#define SC_FreeToken std.Script.FreeToken
|
||||
#define SC_SkipToken std.Script.SkipToken
|
||||
#define SC_MatchToken std.Script.MatchToken
|
||||
#define g_TXcommand std.Script.g_TXcommand
|
||||
|
||||
/*
|
||||
===========================================
|
||||
filesystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define FS_AddGameHierarchy std.AddGameHierarchy
|
||||
#define FS_LoadGameInfo std.LoadGameInfo
|
||||
#define FS_InitRootDir std.InitRootDir
|
||||
#define FS_LoadFile(name, size) std.Fs.LoadFile(name, size)
|
||||
#define FS_Search std.Fs.Search
|
||||
#define FS_WriteFile(name, data, size) std.Fs.WriteFile(name, data, size )
|
||||
#define FS_Open( path, mode ) std.Fs.Open( path, mode )
|
||||
#define FS_Read( file, buffer, size ) std.Fs.Read( file, buffer, size )
|
||||
#define FS_Write( file, buffer, size ) std.Fs.Write( file, buffer, size )
|
||||
#define FS_StripExtension( path ) std.Fs.StripExtension( path )
|
||||
#define FS_DefaultExtension( path, ext ) std.Fs.DefaultExtension( path, ext )
|
||||
#define FS_FileExtension( ext ) std.Fs.FileExtension( ext )
|
||||
#define FS_FileExists( file ) std.Fs.FileExists( file )
|
||||
#define FS_Close( file ) std.Fs.Close( file )
|
||||
#define FS_FileBase( x, y ) std.Fs.FileBase( x, y )
|
||||
#define FS_Find( x ) std.Fs.Search( x, false )
|
||||
#define FS_Printf std.Fs.Printf
|
||||
#define FS_Print std.Fs.Print
|
||||
#define FS_Seek std.Fs.Seek
|
||||
#define FS_Tell std.Fs.Tell
|
||||
#define FS_Gets std.Fs.Gets
|
||||
#define FS_Gamedir std.GameInfo->gamedir
|
||||
#define FS_ClearSearchPath std.Fs.ClearSearchPath
|
||||
int FS_CheckParm (const char *parm);
|
||||
bool FS_GetParmFromCmdLine( char *parm, char *out );
|
||||
rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize );
|
||||
void FS_SaveImage(const char *filename, rgbdata_t *pix );
|
||||
void FS_FreeImage( rgbdata_t *pack );
|
||||
|
||||
|
||||
// virtual files managment
|
||||
#define VFS_Open std.VFs.Open
|
||||
#define VFS_Write std.VFs.Write
|
||||
#define VFS_Read std.VFs.Read
|
||||
#define VFS_Seek std.VFs.Seek
|
||||
#define VFS_Tell std.VFs.Tell
|
||||
#define VFS_Close std.VFs.Close
|
||||
|
||||
// crc stuff
|
||||
#define CRC_Init std.crc_init
|
||||
#define CRC_Block std.crc_block
|
||||
#define CRC_ProcessByte std.crc_process
|
||||
|
||||
#define Sys_DoubleTime std.gettime
|
||||
|
||||
extern stdlib_api_t std;
|
||||
|
||||
#define Msg std.printf
|
||||
#define MsgDev std.dprintf
|
||||
#define MsgWarn std.wprintf
|
||||
#define Sys_Error std.error
|
||||
#define Sys_LoadLibrary std.LoadLibrary
|
||||
#define Sys_FreeLibrary std.FreeLibrary
|
||||
#define Msg std.printf
|
||||
#define MsgDev std.dprintf
|
||||
#define MsgWarn std.wprintf
|
||||
#define Sys_Error std.error
|
||||
#define Sys_DoubleTime std.Com_DoubleTime
|
||||
|
||||
#define Malloc(size) Mem_Alloc(basepool, size)
|
||||
#define Z_Malloc(size) Mem_Alloc(zonepool, size)
|
||||
|
@ -171,6 +101,8 @@ bool CompileSpriteModel ( byte *mempool, const char *name, byte parms );
|
|||
bool ConvertImagePixels ( byte *mempool, const char *name, byte parms );
|
||||
bool PrepareBSPModel ( const char *dir, const char *name, byte params );
|
||||
bool CompileBSPModel ( void );
|
||||
bool PrepareDATProgs ( const char *dir, const char *name, byte params );
|
||||
bool CompileDATProgs ( void );
|
||||
bool PrepareROQVideo ( const char *dir, const char *name, byte params );
|
||||
bool MakeROQ ( void );
|
||||
#endif//UTILS_H
|
|
@ -1,53 +0,0 @@
|
|||
//=======================================================================
|
||||
// Copyright (C) XashXT Group 2006
|
||||
// All Rights Reserved
|
||||
// zip32.h - zlib custom build
|
||||
//=======================================================================
|
||||
#ifndef COM_ZLIB_H
|
||||
#define COM_ZLIB_H
|
||||
|
||||
#define ZLIB_VERSION "1.2.3"
|
||||
#define MAX_WBITS 15
|
||||
|
||||
// zlib errors
|
||||
#define Z_OK 0
|
||||
#define Z_STREAM_END 1
|
||||
#define Z_SYNC_FLUSH 2
|
||||
#define Z_FINISH 4
|
||||
|
||||
typedef struct z_stream_s
|
||||
{
|
||||
byte *next_in; // next input byte
|
||||
uint avail_in; // number of bytes available at next_in
|
||||
dword total_in; // total nb of input bytes read so far
|
||||
byte *next_out; // next output byte should be put there
|
||||
uint avail_out; // remaining free space at next_out
|
||||
dword total_out; // total nb of bytes output so far
|
||||
char *msg; // last error message, NULL if no error
|
||||
byte *state; // not visible by applications
|
||||
byte* (*zalloc)(); // used to allocate the internal state
|
||||
void (*zfree)(); // used to free the internal state
|
||||
byte* opaque; // private data object passed to zalloc and zfree
|
||||
int data_type; // best guess about the data type: binary or text
|
||||
dword adler; // adler32 value of the uncompressed data
|
||||
dword reserved; // reserved for future use
|
||||
} z_stream;
|
||||
|
||||
// exported functions
|
||||
extern int inflate(z_stream *strm, int flush);
|
||||
extern int inflateEnd(z_stream *strm);
|
||||
extern int inflateInit_(z_stream *strm, const char *version, int stream_size);
|
||||
extern int inflateInit2_(z_stream *strm, int windowBits, const char *version, int stream_size);
|
||||
extern int inflateReset(z_stream *strm);
|
||||
extern int deflate (z_stream *strm, int flush);
|
||||
extern int deflateEnd (z_stream *strm);
|
||||
extern int deflateInit_(z_stream *strm, int level, const char *version, int stream_size);
|
||||
extern int deflateInit2_ (z_stream *strm, int level, int method, int windowBits, int memLevel, int strategy, const char *version, int stream_size);
|
||||
extern int deflateReset (z_stream *strm);
|
||||
|
||||
#define inflateInit(strm) inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define inflateInit2(strm, windowBits) inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define deflateInit(strm, level) deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
|
||||
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) deflateInit2_((strm),(level),(method),(windowBits),(memLevel),(strategy), ZLIB_VERSION, sizeof(z_stream))
|
||||
|
||||
#endif//COM_ZLIB_H
|
Binary file not shown.
|
@ -14,51 +14,186 @@ bool host_debug = false;
|
|||
stdlib_api_t std;
|
||||
byte *basepool;
|
||||
byte *zonepool;
|
||||
static double start, end;
|
||||
uint app_name = 0;
|
||||
|
||||
bool InitPlatform ( int argc, char **argv )
|
||||
/*
|
||||
==================
|
||||
CommonInit
|
||||
|
||||
platform.dll needs for some setup operations
|
||||
so do it manually
|
||||
==================
|
||||
*/
|
||||
void InitPlatform ( uint funcname, int argc, char **argv )
|
||||
{
|
||||
byte bspflags = 0, qccflags = 0, roqflags = 0;
|
||||
char source[64], gamedir[64];
|
||||
|
||||
basepool = Mem_AllocPool( "Temp" );
|
||||
zonepool = Mem_AllocPool( "Zone" );
|
||||
imagepool = Mem_AllocPool( "ImageLib Pool" );
|
||||
|
||||
// for custom cmdline parsing
|
||||
com_argc = argc;
|
||||
com_argv = argv;
|
||||
app_name = funcname;
|
||||
|
||||
if(FS_CheckParm("-debug"))
|
||||
host_debug = true;
|
||||
if(FS_CheckParm("-debug")) host_debug = true;
|
||||
|
||||
switch( funcname )
|
||||
{
|
||||
case BSPLIB:
|
||||
if(!FS_GetParmFromCmdLine("-game", gamedir ))
|
||||
strncpy(gamedir, "xash", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+map", source ))
|
||||
strncpy(source, "newmap", sizeof(source));
|
||||
if(FS_CheckParm("-vis")) bspflags |= BSP_ONLYVIS;
|
||||
if(FS_CheckParm("-rad")) bspflags |= BSP_ONLYRAD;
|
||||
if(FS_CheckParm("-full")) bspflags |= BSP_FULLCOMPILE;
|
||||
if(FS_CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS;
|
||||
|
||||
PrepareBSPModel( gamedir, source, bspflags );
|
||||
break;
|
||||
case QCCLIB:
|
||||
if(!FS_GetParmFromCmdLine("-dir", gamedir ))
|
||||
strncpy(gamedir, ".", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+src", source ))
|
||||
strncpy(source, "progs.src", sizeof(source));
|
||||
if(FS_CheckParm("-progdefs")) qccflags |= QCC_PROGDEFS;
|
||||
if(FS_CheckParm("/O0")) qccflags |= QCC_OPT_LEVEL_0;
|
||||
if(FS_CheckParm("/O1")) qccflags |= QCC_OPT_LEVEL_1;
|
||||
if(FS_CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_2;
|
||||
if(FS_CheckParm("/O3")) qccflags |= QCC_OPT_LEVEL_3;
|
||||
|
||||
start = Sys_DoubleTime();
|
||||
PrepareDATProgs( gamedir, source, qccflags );
|
||||
break;
|
||||
case ROQLIB:
|
||||
if(!FS_GetParmFromCmdLine("-dir", gamedir ))
|
||||
strncpy(gamedir, ".", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+src", source ))
|
||||
strncpy(source, "makefile.qc", sizeof(source));
|
||||
|
||||
start = Sys_DoubleTime();
|
||||
PrepareROQVideo( gamedir, source, roqflags );
|
||||
break;
|
||||
case IMGLIB:
|
||||
case SPRITE:
|
||||
case STUDIO:
|
||||
FS_InitRootDir(".");
|
||||
start = Sys_DoubleTime();
|
||||
break;
|
||||
case HOST_OFFLINE:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ClosePlatform ( void )
|
||||
void RunPlatform ( void )
|
||||
{
|
||||
Mem_FreePool( &imagepool);
|
||||
search_t *search;
|
||||
bool (*CompileMod)( byte *mempool, const char *name, byte parms ) = NULL;
|
||||
char filename[MAX_QPATH], typemod[16], searchmask[8][16], errorstring[256];
|
||||
byte parms = 0; // future expansion
|
||||
int i, j, numCompiledMods = 0;
|
||||
|
||||
Mem_Set( searchmask, 0, 8 * 16 );
|
||||
Mem_Set( errorstring, 0, 256 );
|
||||
|
||||
switch(app_name)
|
||||
{
|
||||
case SPRITE:
|
||||
CompileMod = CompileSpriteModel;
|
||||
strcpy(typemod, "sprites" );
|
||||
strcpy(searchmask[0], "*.qc" );
|
||||
break;
|
||||
case STUDIO:
|
||||
CompileMod = CompileStudioModel;
|
||||
strcpy(typemod, "models" );
|
||||
strcpy(searchmask[0], "*.qc" );
|
||||
break;
|
||||
case IMGLIB:
|
||||
CompileMod = ConvertImagePixels;
|
||||
strcpy(typemod, "images" );
|
||||
strcpy(searchmask[0], "*.pcx" ); // quake2 menu images
|
||||
strcpy(searchmask[1], "*.wal" ); // quake2 textures
|
||||
strcpy(searchmask[2], "*.lmp" ); // quake1 menu images
|
||||
strcpy(searchmask[3], "*.mip" ); // quake1 textures
|
||||
Msg("Processing images ...\n\n");
|
||||
break;
|
||||
case BSPLIB:
|
||||
strcpy(typemod, "maps" );
|
||||
strcpy(searchmask[0], "*.map" );
|
||||
CompileBSPModel();
|
||||
break;
|
||||
case QCCLIB:
|
||||
strcpy(typemod, "progs" );
|
||||
strcpy(searchmask[0], "*.src" );
|
||||
strcpy(searchmask[1], "*.qc" ); // no longer used
|
||||
CompileDATProgs();
|
||||
break;
|
||||
case ROQLIB:
|
||||
strcpy(typemod, "videos" );
|
||||
strcpy(searchmask[0], "*.qc" );
|
||||
MakeROQ();
|
||||
break;
|
||||
case HOST_OFFLINE:
|
||||
strcpy(typemod, "things" );
|
||||
strcpy(searchmask[0], "*.*" );
|
||||
break;
|
||||
}
|
||||
if(!CompileMod) goto elapced_time;//back to shutdown
|
||||
|
||||
zonepool = Mem_AllocPool("compiler");
|
||||
if(!FS_GetParmFromCmdLine("-file", filename ))
|
||||
{
|
||||
//search by mask
|
||||
for( i = 0; i < 8; i++)
|
||||
{
|
||||
// skip blank mask
|
||||
if(!strlen(searchmask[i])) continue;
|
||||
search = FS_Search( searchmask[i], true );
|
||||
if(!search) continue; // try next mask
|
||||
|
||||
for( j = 0; j < search->numfilenames; j++ )
|
||||
{
|
||||
if(CompileMod( zonepool, search->filenames[j], parms ))
|
||||
numCompiledMods++;
|
||||
}
|
||||
}
|
||||
if(numCompiledMods == 0)
|
||||
{
|
||||
for(j = 0; j < 8; j++) strcat(errorstring, searchmask[j]);
|
||||
Sys_Error("no %s found in this folder!\n", errorstring );
|
||||
}
|
||||
}
|
||||
else CompileMod( zonepool, filename, parms );
|
||||
|
||||
elapced_time:
|
||||
end = Sys_DoubleTime();
|
||||
Msg ("%5.3f seconds elapsed\n", end - start);
|
||||
if(numCompiledMods > 1) Msg("total %d %s compiled\n", numCompiledMods, typemod );
|
||||
}
|
||||
|
||||
void FreePlatform ( void )
|
||||
{
|
||||
Mem_Check(); // check for leaks
|
||||
Mem_FreePool( &basepool );
|
||||
Mem_FreePool( &zonepool );
|
||||
}
|
||||
|
||||
common_exp_t DLLEXPORT *CreateAPI ( stdlib_api_t *input )
|
||||
launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, void *unused )
|
||||
{
|
||||
static common_exp_t Com;
|
||||
static launch_exp_t Com;
|
||||
|
||||
// Sys_LoadLibrary can create fake instance, to check
|
||||
// api version and api size, but first argument will be 0
|
||||
// and always make exception, run simply check for avoid it
|
||||
if(input) std = *input;
|
||||
std = *input;
|
||||
|
||||
// generic functions
|
||||
Com.api_size = sizeof(common_exp_t);
|
||||
Com.api_size = sizeof(launch_exp_t);
|
||||
|
||||
Com.Init = InitPlatform;
|
||||
Com.Shutdown = ClosePlatform;
|
||||
Com.Main = RunPlatform;
|
||||
Com.Free = FreePlatform;
|
||||
|
||||
Com.LoadImage = FS_LoadImage;
|
||||
Com.FreeImage = FS_FreeImage;
|
||||
Com.SaveImage = FS_SaveImage;
|
||||
|
||||
// get interfaces
|
||||
Com.Compile = Comp_GetAPI();
|
||||
Com.Info = Info_GetAPI();
|
||||
|
||||
return &Com;
|
||||
}
|
|
@ -9,26 +9,15 @@
|
|||
#include <setjmp.h>
|
||||
#include <windows.h>
|
||||
#include <basetypes.h>
|
||||
#include "image.h"
|
||||
#include <ref_system.h>
|
||||
|
||||
extern byte *basepool;
|
||||
extern byte *zonepool;
|
||||
#include <ref_stdlib.h>
|
||||
|
||||
//=====================================
|
||||
// platform export
|
||||
//=====================================
|
||||
bool InitPlatform ( int argc, char **argv );
|
||||
void ClosePlatform ( void );
|
||||
|
||||
compilers_api_t Comp_GetAPI( void );
|
||||
infostring_api_t Info_GetAPI( void );
|
||||
|
||||
//=====================================
|
||||
// filesystem funcs
|
||||
//=====================================
|
||||
rgbdata_t *FS_LoadImage(const char *filename, char *data, int size );
|
||||
void FS_SaveImage(const char *filename, rgbdata_t *buffer );
|
||||
void FS_FreeImage( rgbdata_t *pack );
|
||||
void InitPlatform ( uint funcname, int argc, char **argv ); // init host
|
||||
void RunPlatform ( void ); // host frame
|
||||
void ClosePlatform ( void ); // close host
|
||||
|
||||
#endif//BASEPLATFORM_H
|
|
@ -6642,7 +6642,7 @@ bool PR_ContinueCompile( void )
|
|||
|
||||
if(!progs_src) return false;
|
||||
currentchunk = NULL;
|
||||
SC_ParseToken(&progs_src);
|
||||
Com_ParseToken(&progs_src);
|
||||
|
||||
if(!progs_src)
|
||||
{
|
||||
|
@ -6657,9 +6657,9 @@ bool PR_ContinueCompile( void )
|
|||
return false; // end of compile
|
||||
}
|
||||
|
||||
PR_Message ("%s\n", SC_Token());
|
||||
qc_file = QCC_LoadFile (SC_Token(), true );
|
||||
PR_CompileFile (qc_file, SC_Token());
|
||||
PR_Message ("%s\n", com_token);
|
||||
qc_file = QCC_LoadFile (com_token, true );
|
||||
PR_CompileFile (qc_file, com_token);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -6710,14 +6710,14 @@ void PR_BeginCompilation ( void )
|
|||
|
||||
while(*progs_src && *progs_src < ' ') progs_src++;
|
||||
|
||||
pr_file_p = SC_ParseToken(&progs_src);
|
||||
strcpy (progsoutname, SC_Token());
|
||||
FS_StripExtension( SC_Token() );
|
||||
pr_file_p = Com_ParseToken(&progs_src);
|
||||
strcpy (progsoutname, com_token);
|
||||
FS_StripExtension( com_token );
|
||||
|
||||
if (FS_CheckParm("-asm")) asmfile = FS_Open(va("%s.asm", SC_Token()), "wb" );
|
||||
if (FS_CheckParm("-asm")) asmfile = FS_Open(va("%s.asm", com_token), "wb" );
|
||||
|
||||
// msvc6.0 style message
|
||||
PR_Message("------------Configuration: %s - Vm16 %s------------\n", SC_Token(), opt_writelinenums ? "Debug" : "Release" );
|
||||
PR_Message("------------Configuration: %s - Vm16 %s------------\n", com_token, opt_writelinenums ? "Debug" : "Release" );
|
||||
|
||||
currentchunk = NULL;
|
||||
saved_progs_src = progs_src; // save it for prototyping
|
||||
|
|
|
@ -542,13 +542,13 @@ bool PR_Precompiler(void)
|
|||
pr_file_p = directive+6;
|
||||
while(*pr_file_p <= ' ') pr_file_p++;
|
||||
|
||||
SC_Token()[0] = '\0';
|
||||
com_token[0] = '\0';
|
||||
for(a = 0; *pr_file_p != '\n' && *pr_file_p != '\0'; pr_file_p++) // read on until the end of the line
|
||||
{
|
||||
if ((*pr_file_p == ' ' || *pr_file_p == '\t'|| *pr_file_p == '(') && !*SC_Token())
|
||||
if ((*pr_file_p == ' ' || *pr_file_p == '\t'|| *pr_file_p == '(') && !*com_token)
|
||||
{
|
||||
msg[a] = '\0';
|
||||
strcpy(SC_Token(), msg);
|
||||
strcpy(com_token, msg);
|
||||
a=0;
|
||||
continue;
|
||||
}
|
||||
|
@ -562,9 +562,9 @@ bool PR_Precompiler(void)
|
|||
*end = '\0';
|
||||
}
|
||||
|
||||
if (!*SC_Token())
|
||||
if (!*com_token)
|
||||
{
|
||||
strcpy(SC_Token(), msg);
|
||||
strcpy(com_token, msg);
|
||||
msg[0] = '\0';
|
||||
}
|
||||
|
||||
|
@ -574,7 +574,7 @@ bool PR_Precompiler(void)
|
|||
*end = '\0';
|
||||
}
|
||||
|
||||
if (!stricmp(SC_Token(), "DONT_COMPILE_THIS_FILE"))
|
||||
if (!stricmp(com_token, "DONT_COMPILE_THIS_FILE"))
|
||||
{
|
||||
while (*pr_file_p)
|
||||
{
|
||||
|
@ -586,7 +586,7 @@ bool PR_Precompiler(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else if (!stricmp(SC_Token(), "COPYRIGHT"))
|
||||
else if (!stricmp(com_token, "COPYRIGHT"))
|
||||
{
|
||||
if (strlen(msg) >= sizeof(v_copyright))
|
||||
PR_ParseWarning(WARN_STRINGTOOLONG, "Copyright message is too long\n");
|
||||
|
@ -596,7 +596,7 @@ bool PR_Precompiler(void)
|
|||
{
|
||||
ForcedCRC = atoi(msg);
|
||||
}
|
||||
else if (!stricmp(SC_Token(), "TARGET"))
|
||||
else if (!stricmp(com_token, "TARGET"))
|
||||
{
|
||||
if (!stricmp(msg, "STANDARD")) target_version = QPROGS_VERSION;
|
||||
else if (!stricmp(msg, "ID")) target_version = QPROGS_VERSION;
|
||||
|
@ -604,14 +604,14 @@ bool PR_Precompiler(void)
|
|||
else if (!stricmp(msg, "VPROGS"))target_version = VPROGS_VERSION;
|
||||
else PR_ParseWarning(WARN_BADTARGET, "Unknown target \'%s\'. Ignored.", msg);
|
||||
}
|
||||
else if (!stricmp(SC_Token(), "warning"))
|
||||
else if (!stricmp(com_token, "warning"))
|
||||
{
|
||||
int st;
|
||||
|
||||
SC_ParseToken(&msg);
|
||||
if (!stricmp(SC_Token(), "enable") || !stricmp(SC_Token(), "on")) st = 0;
|
||||
else if (!stricmp(SC_Token(), "disable") || !stricmp(SC_Token(), "off")) st = 1;
|
||||
else if (!stricmp(SC_Token(), "toggle")) st = 2;
|
||||
Com_ParseToken(&msg);
|
||||
if (!stricmp(com_token, "enable") || !stricmp(com_token, "on")) st = 0;
|
||||
else if (!stricmp(com_token, "disable") || !stricmp(com_token, "off")) st = 1;
|
||||
else if (!stricmp(com_token, "toggle")) st = 2;
|
||||
else
|
||||
{
|
||||
PR_ParseWarning(WARN_BADPRAGMA, "warning state not recognized");
|
||||
|
@ -620,8 +620,8 @@ bool PR_Precompiler(void)
|
|||
if (st >= 0)
|
||||
{
|
||||
int wn;
|
||||
SC_ParseToken(&msg); // just a number of warning
|
||||
wn = atoi(SC_Token());
|
||||
Com_ParseToken(&msg); // just a number of warning
|
||||
wn = atoi(com_token);
|
||||
if (wn < 0 || wn > WARN_CONSTANTCOMPARISON)
|
||||
{
|
||||
PR_ParseWarning(WARN_BADPRAGMA, "warning id not recognised");
|
||||
|
@ -633,7 +633,7 @@ bool PR_Precompiler(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
else PR_ParseWarning(WARN_BADPRAGMA, "Unknown pragma \'%s\'", SC_Token());
|
||||
else PR_ParseWarning(WARN_BADPRAGMA, "Unknown pragma \'%s\'", com_token);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1648,12 +1648,12 @@ int PR_CheakCompConst(void)
|
|||
else
|
||||
{ // stringify
|
||||
pr_file_p++;
|
||||
SC_ParseWord(&pr_file_p);
|
||||
Com_ParseWord(&pr_file_p);
|
||||
if (!pr_file_p) break;
|
||||
|
||||
for (p = 0; p < param; p++)
|
||||
{
|
||||
if (!STRCMP(SC_Token(), c->params[p]))
|
||||
if (!STRCMP(com_token, c->params[p]))
|
||||
{
|
||||
strcat(buffer, "\"");
|
||||
strcat(buffer, paramoffset[p]);
|
||||
|
@ -1664,24 +1664,24 @@ int PR_CheakCompConst(void)
|
|||
if (p == param)
|
||||
{
|
||||
strcat(buffer, "#");
|
||||
strcat(buffer, SC_Token());
|
||||
strcat(buffer, com_token);
|
||||
PR_ParseWarning(0, "Stringification ignored");
|
||||
}
|
||||
continue;// already did this one
|
||||
}
|
||||
}
|
||||
SC_ParseWord(&pr_file_p);
|
||||
Com_ParseWord(&pr_file_p);
|
||||
if (!pr_file_p) break;
|
||||
|
||||
for (p = 0; p < param; p++)
|
||||
{
|
||||
if (!STRCMP(SC_Token(), c->params[p]))
|
||||
if (!STRCMP(com_token, c->params[p]))
|
||||
{
|
||||
strcat(buffer, paramoffset[p]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (p == param) strcat(buffer, SC_Token());
|
||||
if (p == param) strcat(buffer, com_token);
|
||||
}
|
||||
|
||||
for (p = 0; p < param-1; p++)
|
||||
|
@ -1794,7 +1794,7 @@ const_t *PR_CheckCompConstDefined(char *def)
|
|||
==============
|
||||
PR_Lex
|
||||
|
||||
Advanced version of SC_ParseToken()
|
||||
Advanced version of Com_ParseToken()
|
||||
Sets pr_token, pr_token_type, and possibly pr_immediate and pr_immediate_type
|
||||
==============
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
//=======================================================================
|
||||
|
||||
#include "qcclib.h"
|
||||
#include "zip32.h"
|
||||
|
||||
void Hash_InitTable(hashtable_t *table, int numbucks)
|
||||
{
|
||||
|
@ -192,7 +191,6 @@ int PR_decode(int complen, int len, int method, char *src, char **dst)
|
|||
{
|
||||
int i;
|
||||
char *buffer = *dst;
|
||||
z_stream strm = {src, complen, 0, buffer, len, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
switch(method)
|
||||
{
|
||||
|
@ -213,14 +211,7 @@ int PR_decode(int complen, int len, int method, char *src, char **dst)
|
|||
for (i = 0; i < len; i++) buffer[i] = src[i] ^ 0xA5;
|
||||
break;
|
||||
case CMPW_DEFLATE:
|
||||
inflateInit( &strm );
|
||||
if (Z_STREAM_END != inflate( &strm, Z_FINISH )) // decompress it in one go.
|
||||
{
|
||||
if(!strlen(strm.msg))MsgDev(D_WARN, "PR_decode: failed block decompression\n" );
|
||||
else MsgDev(D_WARN, "PR_decode: failed block decompression: %s\n", strm.msg );
|
||||
return false;
|
||||
}
|
||||
inflateEnd( &strm );
|
||||
VFS_Unpack( src, complen, dst, len );
|
||||
break;
|
||||
default:
|
||||
MsgDev(D_WARN, "PR_decode: invalid method\n");
|
||||
|
@ -237,8 +228,6 @@ PR_encode
|
|||
int PR_encode(int len, int method, char *src, vfile_t *handle)
|
||||
{
|
||||
int i = 0;
|
||||
char out[8192]; // chunk size
|
||||
z_stream strm = {src, len, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
switch(method)
|
||||
{
|
||||
|
@ -250,17 +239,7 @@ int PR_encode(int len, int method, char *src, vfile_t *handle)
|
|||
VFS_Write(handle, src, len);
|
||||
return len;
|
||||
case CMPW_DEFLATE:
|
||||
deflateInit( &strm, 9 ); // Z_BEST_COMPRESSION
|
||||
while(deflate( &strm, Z_FINISH) == Z_OK)
|
||||
{
|
||||
VFS_Write( handle, out, sizeof(out) - strm.avail_out);
|
||||
i += sizeof(out) - strm.avail_out;
|
||||
strm.next_out = out;
|
||||
strm.avail_out = sizeof(out);
|
||||
}
|
||||
VFS_Write( handle, out, sizeof(out) - strm.avail_out );
|
||||
i += sizeof(out) - strm.avail_out;
|
||||
deflateEnd( &strm );
|
||||
i = VFS_Write2( handle, src, len );
|
||||
return i;
|
||||
default:
|
||||
MsgDev(D_WARN, "PR_encode: invalid method\n");
|
||||
|
@ -1091,18 +1070,18 @@ byte *PR_CreateProgsSRC( void )
|
|||
|
||||
for(i = 0; i < qc->numfilenames; i++)
|
||||
{
|
||||
if(FS_LoadScript( qc->filenames[i], NULL, 0 ))
|
||||
if(Com_LoadScript( qc->filenames[i], NULL, 0 ))
|
||||
{
|
||||
while ( 1 )
|
||||
{
|
||||
// parse all sources for "end_sys_globals"
|
||||
if (!SC_GetToken( true )) break; //EOF
|
||||
if(SC_MatchToken( "end_sys_globals" ))
|
||||
if (!Com_GetToken( true )) break; //EOF
|
||||
if(Com_MatchToken( "end_sys_globals" ))
|
||||
{
|
||||
strncpy(headers[0], qc->filenames[i], MAX_QPATH );
|
||||
found++;
|
||||
}
|
||||
else if(SC_MatchToken( "end_sys_fields" ))
|
||||
else if(Com_MatchToken( "end_sys_fields" ))
|
||||
{
|
||||
strncpy(headers[1], qc->filenames[i], MAX_QPATH );
|
||||
found++;
|
||||
|
|
|
@ -13,14 +13,11 @@ DllMain
|
|||
|
||||
==================
|
||||
*/
|
||||
launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input )
|
||||
launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, generic_api_t *unused )
|
||||
{
|
||||
static launch_exp_t Editor;
|
||||
|
||||
// Sys_LoadLibrary can create fake instance, to check
|
||||
// api version and api size, but first argument will be 0
|
||||
// and always make exception, run simply check for avoid it
|
||||
if(input)std = *input;
|
||||
std = *input;
|
||||
|
||||
Editor.api_size = sizeof(launch_exp_t);
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
#include <string.h>
|
||||
#include <basetypes.h>
|
||||
#include <ref_system.h>
|
||||
#include <ref_stdlib.h>
|
||||
|
||||
#include "mxtk.h"
|
||||
#include "options.h"
|
||||
|
@ -22,18 +23,14 @@
|
|||
//=====================================
|
||||
// main editor funcs
|
||||
//=====================================
|
||||
void InitEditor ( char *funcname, int argc, char **argv );
|
||||
void InitEditor ( uint funcname, int argc, char **argv );
|
||||
void EditorMain ( void );
|
||||
void FreeEditor ( void );
|
||||
|
||||
extern int com_argc;
|
||||
extern int dev_mode;
|
||||
extern bool debug_mode;
|
||||
extern common_exp_t *com;
|
||||
extern char *com_argv[MAX_NUM_ARGVS];
|
||||
int CheckParm (const char *parm);
|
||||
bool _GetParmFromCmdLine( char *parm, char *out, size_t size );
|
||||
#define GetParmFromCmdLine( parm, out ) _GetParmFromCmdLine( parm, out, sizeof(out))
|
||||
|
||||
/*
|
||||
===========================================
|
||||
|
@ -49,8 +46,6 @@ extern stdlib_api_t std;
|
|||
#define MsgDev GUI_MsgDev
|
||||
#define MsgWarn GUI_MsgWarn
|
||||
#define Sys_Error std.error
|
||||
#define Sys_LoadLibrary std.LoadLibrary
|
||||
#define Sys_FreeLibrary std.FreeLibrary
|
||||
|
||||
typedef enum {
|
||||
Action,
|
||||
|
@ -86,6 +81,6 @@ typedef struct window_s
|
|||
int ( *handleEvent ) ( event_t *event );
|
||||
HWND Handle;
|
||||
|
||||
}window_t;
|
||||
} window_t;
|
||||
|
||||
#endif//GENERICEDIT_H
|
|
@ -31,10 +31,8 @@ typedef struct tag_dlghdr
|
|||
|
||||
GUI_Form s_gui;
|
||||
wnd_options_t w_opts; //window options
|
||||
common_exp_t *com; //common utils
|
||||
static bool editor_init = false;
|
||||
static char textbuffer[MAX_INPUTLINE];
|
||||
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, false, sizeof(common_exp_t) };
|
||||
dll_info_t richedit_dll = { "riched32.dll", NULL, NULL, NULL, NULL, false, 0 };
|
||||
|
||||
|
||||
|
@ -366,7 +364,7 @@ void GUI_CreateOptionsWindow( void )
|
|||
|
||||
int w_pos, h_pos;
|
||||
//int WNDSTYLE = WS_POPUP | WS_BORDER | WS_CAPTION | WS_MINIMIZEBOX;
|
||||
int WNDSTYLE = WS_POPUP | WS_BORDER | WS_SYSMENU | WS_CAPTION;
|
||||
int WNDSTYLE = WS_POPUP | WS_CAPTION;
|
||||
int TABSTYLE = WS_CHILD | WS_VISIBLE | WS_TABSTOP | TCS_TOOLTIPS;
|
||||
int bpos_x, bpos_y;
|
||||
|
||||
|
@ -377,7 +375,7 @@ void GUI_CreateOptionsWindow( void )
|
|||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = s_gui.gHinst;
|
||||
wc.hIcon = LoadIcon(NULL, NULL);
|
||||
wc.hIcon = LoadIcon( s_gui.gHinst, NULL );
|
||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) COLOR_3DSHADOW;
|
||||
wc.lpszMenuName = NULL;
|
||||
|
@ -423,11 +421,9 @@ void GUI_ResetWndOptions( void )
|
|||
char dev_level[4];
|
||||
|
||||
//get info about debug mode
|
||||
if(CheckParm ("-debug")) debug_mode = true;
|
||||
if(GetParmFromCmdLine("-dev", dev_level ))
|
||||
if(FS_CheckParm ("-debug")) debug_mode = true;
|
||||
if(FS_GetParmFromCmdLine("-dev", dev_level ))
|
||||
dev_mode = atoi(dev_level);
|
||||
|
||||
s_gui.gHinst = (HINSTANCE) GetModuleHandle( NULL );
|
||||
|
||||
// reset options
|
||||
w_opts.id = IDEDITORHEADER;
|
||||
|
@ -453,35 +449,10 @@ void GUI_LoadWndOptions( wnd_options_t *settings )
|
|||
s_gui.height = w_opts.height;
|
||||
}
|
||||
|
||||
bool GUI_LoadPlatfrom( char *funcname, int argc, char **argv )
|
||||
bool GUI_LoadPlatfrom( uint funcname, int argc, char **argv )
|
||||
{
|
||||
stdlib_api_t io; //common callback
|
||||
common_t CreatePlat;
|
||||
|
||||
// create callbacks for common.dll
|
||||
io = std;
|
||||
|
||||
// overload some functions
|
||||
io.printf = GUI_Msg;
|
||||
io.dprintf = GUI_MsgDev;
|
||||
io.wprintf = GUI_MsgWarn;
|
||||
io.error = GUI_Error;
|
||||
io.print = GUI_Print;
|
||||
|
||||
// loading common.dll
|
||||
if (!Sys_LoadLibrary( &common_dll ))
|
||||
{
|
||||
GUI_Error("couldn't find common.dll\n");
|
||||
return false;
|
||||
}
|
||||
CreatePlat = (void *)common_dll.main;
|
||||
com = CreatePlat( &io );//make links
|
||||
|
||||
//initialziing common.dll
|
||||
com->Init( argc, argv );
|
||||
|
||||
std.Fs.ClearSearchPath();
|
||||
std.AddGameHierarchy( "bin" );
|
||||
FS_ClearSearchPath();
|
||||
FS_AddGameHierarchy( "bin" );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -936,7 +907,7 @@ static LRESULT CALLBACK WndProc (HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM
|
|||
return DefWindowProc (hwnd, uMessage, wParam, lParam);
|
||||
}
|
||||
|
||||
void InitEditor ( char *funcname, int argc, char **argv )
|
||||
void InitEditor ( uint funcname, int argc, char **argv )
|
||||
{
|
||||
HDC hDC;
|
||||
WNDCLASS wc;
|
||||
|
@ -945,6 +916,7 @@ void InitEditor ( char *funcname, int argc, char **argv )
|
|||
int iErrors = 0;
|
||||
|
||||
memset( &wc, 0, sizeof( wc ));
|
||||
s_gui.gHinst = (HINSTANCE)GetModuleHandle( NULL );
|
||||
|
||||
com_argc = argc;
|
||||
memcpy(com_argv, argv, MAX_NUM_ARGVS );
|
||||
|
@ -954,7 +926,7 @@ void InitEditor ( char *funcname, int argc, char **argv )
|
|||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = s_gui.gHinst;
|
||||
wc.hIcon = LoadIcon (wc.hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||
wc.hIcon = LoadIcon (s_gui.gHinst, MAKEINTRESOURCE(IDI_ICON1));
|
||||
wc.hCursor = LoadCursor (NULL, IDC_ARROW);
|
||||
wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
|
||||
wc.lpszMenuName = NULL;
|
||||
|
@ -989,7 +961,7 @@ void InitEditor ( char *funcname, int argc, char **argv )
|
|||
wnd_options_t *config_dat;
|
||||
int config_size;
|
||||
|
||||
config_dat = (wnd_options_t *)std.Fs.LoadFile( "editor.dat", &config_size );
|
||||
config_dat = (wnd_options_t *)FS_LoadFile( "editor.dat", &config_size );
|
||||
|
||||
if(config_dat) //verify our config before read
|
||||
{
|
||||
|
@ -1040,25 +1012,14 @@ void EditorMain ( void )
|
|||
}
|
||||
}
|
||||
|
||||
if(common_dll.link)
|
||||
{
|
||||
// save our settings
|
||||
std.Fs.WriteFile("editor.dat", &w_opts, w_opts.csize );
|
||||
}
|
||||
// save our settings
|
||||
FS_WriteFile("editor.dat", &w_opts, w_opts.csize );
|
||||
}
|
||||
|
||||
void FreeEditor ( void )
|
||||
{
|
||||
// free richedit32
|
||||
Sys_FreeLibrary( &richedit_dll );
|
||||
|
||||
// free common
|
||||
if(common_dll.link)
|
||||
{
|
||||
com->Shutdown();
|
||||
Sys_FreeLibrary(&common_dll);
|
||||
}
|
||||
|
||||
GUI_RemoveAccelTable();
|
||||
UnregisterClass (CLASSNAME, s_gui.gHinst);
|
||||
}
|
|
@ -208,12 +208,12 @@ bool CG_ParseArgs( int num_argc )
|
|||
{
|
||||
cls.cg_argc = 0;
|
||||
memset(cls.cg_argv, 0, MAX_PARMS * MAX_QPATH );
|
||||
strncpy( cls.cg_progname, COM_Token, MAX_QPATH );
|
||||
strncpy( cls.cg_progname, com_token, MAX_QPATH );
|
||||
|
||||
// bound range silently
|
||||
num_argc = bound(0, num_argc, MAX_PARMS - 1);
|
||||
|
||||
while(COM_TryToken())
|
||||
while(Com_TryToken())
|
||||
{
|
||||
if(!num_argc) continue; // nothing to handle
|
||||
if(num_argc > 0 && cls.cg_argc > num_argc - 1 )
|
||||
|
@ -221,11 +221,11 @@ bool CG_ParseArgs( int num_argc )
|
|||
MsgDev(D_ERROR, "CG_ParseArgs: %s have too many parameters\n", cls.cg_progname );
|
||||
return false; // stack overflow
|
||||
}
|
||||
else if(COM_MatchToken(";")) break; // end of parsing
|
||||
else if(COM_MatchToken(",")) cls.cg_argc++; // new argument
|
||||
else if(COM_MatchToken("(") || COM_MatchToken(")"))
|
||||
else if(Com_MatchToken(";")) break; // end of parsing
|
||||
else if(Com_MatchToken(",")) cls.cg_argc++; // new argument
|
||||
else if(Com_MatchToken("(") || Com_MatchToken(")"))
|
||||
continue; // skip punctuation
|
||||
else strncpy(cls.cg_argv[cls.cg_argc], COM_Token, MAX_QPATH ); // fill stack
|
||||
else strncpy(cls.cg_argv[cls.cg_argc], com_token, MAX_QPATH ); // fill stack
|
||||
}
|
||||
|
||||
if(num_argc > 0 && cls.cg_argc < num_argc - 1)
|
||||
|
@ -239,18 +239,18 @@ void CG_SkipBlock( void )
|
|||
int old_depth = cls.cg_program_depth;
|
||||
|
||||
do {
|
||||
if(COM_MatchToken("{"))
|
||||
if(Com_MatchToken("{"))
|
||||
{
|
||||
// for bounds cheking
|
||||
cls.cg_program_depth++;
|
||||
}
|
||||
else if(COM_MatchToken("}"))
|
||||
else if(Com_MatchToken("}"))
|
||||
{
|
||||
cls.cg_program_depth--;
|
||||
break;
|
||||
}
|
||||
while(COM_TryToken());
|
||||
} while(COM_GetToken( true ));
|
||||
while(Com_TryToken());
|
||||
} while(Com_GetToken( true ));
|
||||
|
||||
if(cls.cg_program_depth != old_depth)
|
||||
{
|
||||
|
@ -731,16 +731,16 @@ void CG_ExecuteProgram( char *section )
|
|||
bool skip = true;
|
||||
int value = 0;
|
||||
|
||||
COM_ResetScript();
|
||||
Com_ResetScript();
|
||||
cls.cg_program_depth = 0;
|
||||
|
||||
while(COM_GetToken( true ))
|
||||
while(Com_GetToken( true ))
|
||||
{
|
||||
// first, we must find start of section
|
||||
if(COM_MatchToken("void"))
|
||||
if(Com_MatchToken("void"))
|
||||
{
|
||||
COM_GetToken( false ); // get section name
|
||||
if(COM_MatchToken( section )) skip = false;
|
||||
Com_GetToken( false ); // get section name
|
||||
if(Com_MatchToken( section )) skip = false;
|
||||
CG_ParseArgs( 1 ); // go to end of line
|
||||
}
|
||||
|
||||
|
@ -748,12 +748,12 @@ void CG_ExecuteProgram( char *section )
|
|||
//Msg("execute %s\n", section );
|
||||
|
||||
// exec hud program
|
||||
if(COM_MatchToken("{"))
|
||||
if(Com_MatchToken("{"))
|
||||
{
|
||||
cls.cg_program_depth++;
|
||||
continue;
|
||||
}
|
||||
else if(COM_MatchToken("}"))
|
||||
else if(Com_MatchToken("}"))
|
||||
{
|
||||
cls.cg_program_depth--;
|
||||
if(!cls.cg_program_depth) break; // end of section
|
||||
|
@ -761,7 +761,7 @@ void CG_ExecuteProgram( char *section )
|
|||
}
|
||||
|
||||
// builtins
|
||||
if(COM_MatchToken("if"))
|
||||
if(Com_MatchToken("if"))
|
||||
{
|
||||
bool equal = true;
|
||||
|
||||
|
@ -775,19 +775,19 @@ void CG_ExecuteProgram( char *section )
|
|||
}
|
||||
else CG_SkipBlock(); // skip if{ }
|
||||
}
|
||||
else if(COM_MatchToken("SetAlias"))
|
||||
else if(Com_MatchToken("SetAlias"))
|
||||
{
|
||||
// set alias name for stats numbers
|
||||
if(!CG_ParseArgs( 2 )) continue;
|
||||
CG_SetAlias(cls.cg_argv[0], atoi(cls.cg_argv[1]));
|
||||
}
|
||||
else if(COM_MatchToken("LoadPic"))
|
||||
else if(Com_MatchToken("LoadPic"))
|
||||
{
|
||||
// cache hud pics
|
||||
if(!CG_ParseArgs( 1 )) continue;
|
||||
re->RegisterPic(cls.cg_argv[0]);
|
||||
}
|
||||
else if(COM_MatchToken("DrawField"))
|
||||
else if(Com_MatchToken("DrawField"))
|
||||
{
|
||||
// displayed health, armor, e.t.c.
|
||||
if(!CG_ParseArgs( 4 )) continue;
|
||||
|
@ -795,37 +795,37 @@ void CG_ExecuteProgram( char *section )
|
|||
MsgDev(D_WARN, "%s: can't use undefined alias %s\n", cls.cg_progname, cls.cg_argv[0]);
|
||||
else CG_DrawField( value, atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]));
|
||||
}
|
||||
else if(COM_MatchToken("DrawPic"))
|
||||
else if(Com_MatchToken("DrawPic"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 3 )) continue;
|
||||
SCR_DrawPic( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), 48, 48, CG_ImageIndex(cls.cg_argv[0]));
|
||||
}
|
||||
else if(COM_MatchToken("DrawStretchPic"))
|
||||
else if(Com_MatchToken("DrawStretchPic"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 5 )) continue;
|
||||
SCR_DrawPic( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), atoi(cls.cg_argv[3]), atoi(cls.cg_argv[4]), cls.cg_argv[0]);
|
||||
}
|
||||
else if(COM_MatchToken("SetColor"))
|
||||
else if(Com_MatchToken("SetColor"))
|
||||
{
|
||||
// set custom color
|
||||
if(!CG_ParseArgs( 4 )) continue;
|
||||
CG_SetColor(atof(cls.cg_argv[0]), atof(cls.cg_argv[1]), atof(cls.cg_argv[2]), atof(cls.cg_argv[3]));
|
||||
}
|
||||
else if(COM_MatchToken("DrawCenterPic"))
|
||||
else if(Com_MatchToken("DrawCenterPic"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 3 )) continue;
|
||||
CG_DrawCenterPic( atoi(cls.cg_argv[1]), atoi(cls.cg_argv[2]), cls.cg_argv[0]);
|
||||
}
|
||||
else if(COM_MatchToken("DrawLevelShot"))
|
||||
else if(Com_MatchToken("DrawLevelShot"))
|
||||
{
|
||||
// draw named pic
|
||||
if(!CG_ParseArgs( 0 )) continue;
|
||||
SCR_DrawPic(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, cl.levelshot_name );
|
||||
}
|
||||
else if(COM_MatchToken("DrawCrosshair"))
|
||||
else if(Com_MatchToken("DrawCrosshair"))
|
||||
{
|
||||
// draw crosshair
|
||||
if(!crosshair->value) continue;
|
||||
|
@ -834,56 +834,56 @@ void CG_ExecuteProgram( char *section )
|
|||
}
|
||||
/*if(!strcmp(token, "x"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "y"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "xl"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "xr"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = viddef.width + atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "xv"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "yt"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "yb"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = viddef.height + atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "yv"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "pic"))
|
||||
{
|
||||
// draw a pic from a stat number
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
value = cl.frame.playerstate.stats[atoi(token)];
|
||||
if (value >= MAX_IMAGES) continue;
|
||||
SCR_DrawPic( x, y, 48, 48, cl.configstrings[CS_IMAGES+value] );
|
||||
|
@ -894,24 +894,24 @@ void CG_ExecuteProgram( char *section )
|
|||
// draw a deathmatch client block
|
||||
int score, ping, time;
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
value = atoi(token);
|
||||
if (value >= MAX_CLIENTS || value < 0)
|
||||
Host_Error("client >= MAX_CLIENTS\n");
|
||||
ci = &cl.clientinfo[value];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
score = atoi(token);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
ping = atoi(token);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
time = atoi(token);
|
||||
|
||||
DrawAltString (x+32, y, ci->name);
|
||||
|
@ -931,21 +931,21 @@ void CG_ExecuteProgram( char *section )
|
|||
int score, ping;
|
||||
char block[80];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
x = viddef.width/2 - 160 + atoi(token);
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
y = viddef.height/2 - 120 + atoi(token);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
value = atoi(token);
|
||||
if (value >= MAX_CLIENTS || value < 0)
|
||||
Host_Error("client >= MAX_CLIENTS\n");
|
||||
ci = &cl.clientinfo[value];
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
score = atoi(token);
|
||||
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
ping = atoi(token);
|
||||
if (ping > 999) ping = 999;
|
||||
|
||||
|
@ -959,16 +959,16 @@ void CG_ExecuteProgram( char *section )
|
|||
if (!strcmp(token, "picn"))
|
||||
{
|
||||
// draw a pic from a name
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
re->DrawPic (x, y, token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "num"))
|
||||
{
|
||||
// draw a number
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
width = atoi(token);
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
value = cl.frame.playerstate.stats[atoi(token)];
|
||||
SCR_DrawField (x, y, 0, width, value);
|
||||
continue;
|
||||
|
@ -1026,7 +1026,7 @@ void CG_ExecuteProgram( char *section )
|
|||
}
|
||||
if (!strcmp(token, "stat_string"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
index = atoi(token);
|
||||
if (index < 0 || index >= MAX_CONFIGSTRINGS)
|
||||
Host_Error("Bad stat_string index\n");
|
||||
|
@ -1038,25 +1038,25 @@ void CG_ExecuteProgram( char *section )
|
|||
}
|
||||
if (!strcmp(token, "cstring"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
DrawHUDString (token, x, y, 320, 0);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "string"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
DrawString (x, y, token);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "cstring2"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
DrawHUDString (token, x, y, 320,0x80);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(token, "string2"))
|
||||
{
|
||||
token = COM_Parse (&s);
|
||||
token = Com_Parse (&s);
|
||||
DrawAltString (x, y, token);
|
||||
continue;
|
||||
}*/
|
||||
|
@ -1157,6 +1157,6 @@ initialize cg
|
|||
void CG_Init( void )
|
||||
{
|
||||
cls.cg_numaliases = 0; // reset hudprogram aliasnames
|
||||
COM_LoadScript( "scripts/hud.txt", NULL, 0 );
|
||||
Com_LoadScript( "scripts/hud.txt", NULL, 0 );
|
||||
CG_ExecuteProgram( "Hud_Setup" ); // get alias names
|
||||
}
|
|
@ -12,7 +12,8 @@ vec4_t console_color = {1.0, 1.0, 1.0, 1.0};
|
|||
int g_console_field_width = 78;
|
||||
|
||||
#define NUM_CON_TIMES 4
|
||||
#define CON_TEXTSIZE MAX_INPUTLINE * 32 // 512 kb buffer
|
||||
#define CON_TEXTSIZE MAX_INPUTLINE * 8 // 128 kb buffer
|
||||
#define DEFAULT_CONSOLE_WIDTH 78
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -104,69 +105,6 @@ void Con_Clear_f (void)
|
|||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
Con_Bottom(); // go to end
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
Con_Dump_f
|
||||
|
||||
Save the console contents out to a file
|
||||
================
|
||||
*/
|
||||
void Con_Dump_f (void)
|
||||
{
|
||||
int l, x, i;
|
||||
short *line;
|
||||
file_t *f;
|
||||
char buffer[1024];
|
||||
char name[MAX_OSPATH];
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("usage: condump <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
sprintf (name, "%s.txt", Cmd_Argv(1));
|
||||
|
||||
Msg ("Dumped console text to %s.\n", name);
|
||||
f = FS_Open (name, "w");
|
||||
if (!f)
|
||||
{
|
||||
Msg ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// skip empty lines
|
||||
for (l = con.current - con.totallines + 1; l <= con.current; l++)
|
||||
{
|
||||
line = con.text + (l%con.totallines)*con.linewidth;
|
||||
for (x = 0; x < con.linewidth; x++)
|
||||
{
|
||||
if ((line[x] & 0xff) != ' ')
|
||||
break;
|
||||
}
|
||||
if (x != con.linewidth) break;
|
||||
}
|
||||
|
||||
// write the remaining lines
|
||||
buffer[con.linewidth] = 0;
|
||||
for ( ; l <= con.current; l++)
|
||||
{
|
||||
line = con.text + (l%con.totallines)*con.linewidth;
|
||||
for(i = 0; i < con.linewidth; i++)
|
||||
buffer[i] = line[i] & 0xff;
|
||||
for (x = con.linewidth - 1; x >= 0; x--)
|
||||
{
|
||||
if (buffer[x] == ' ') buffer[x] = 0;
|
||||
else break;
|
||||
}
|
||||
strcat( buffer, "\n" );
|
||||
FS_Printf (f, "%s\n", buffer);
|
||||
}
|
||||
FS_Close (f);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
|
@ -177,7 +115,7 @@ void Con_ClearNotify (void)
|
|||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<NUM_CON_TIMES ; i++)
|
||||
for (i = 0; i < NUM_CON_TIMES; i++)
|
||||
con.times[i] = 0;
|
||||
}
|
||||
|
||||
|
@ -213,20 +151,21 @@ If the line width has changed, reformat the buffer.
|
|||
*/
|
||||
void Con_CheckResize (void)
|
||||
{
|
||||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
char tbuf[CON_TEXTSIZE];
|
||||
int i, j, width, oldwidth, oldtotallines, numlines, numchars;
|
||||
short tbuf[CON_TEXTSIZE];
|
||||
|
||||
width = (viddef.width >> 3) - 2;
|
||||
width = (SCREEN_WIDTH / SMALLCHAR_WIDTH) - 2;
|
||||
|
||||
if (width == con.linewidth)
|
||||
return;
|
||||
|
||||
if (width < 1) // video hasn't been initialized yet
|
||||
{
|
||||
width = 38;
|
||||
width = DEFAULT_CONSOLE_WIDTH;
|
||||
con.linewidth = width;
|
||||
con.totallines = CON_TEXTSIZE / con.linewidth;
|
||||
memset (con.text, ' ', CON_TEXTSIZE);
|
||||
for(i = 0; i < CON_TEXTSIZE; i++)
|
||||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -244,16 +183,16 @@ void Con_CheckResize (void)
|
|||
if (con.linewidth < numchars)
|
||||
numchars = con.linewidth;
|
||||
|
||||
memcpy (tbuf, con.text, CON_TEXTSIZE);
|
||||
memset (con.text, ' ', CON_TEXTSIZE);
|
||||
Mem_Copy(tbuf, con.text, CON_TEXTSIZE * sizeof(short));
|
||||
for(i = 0; i < CON_TEXTSIZE; i++)
|
||||
con.text[i] = (ColorIndex(COLOR_WHITE)<<8) | ' ';
|
||||
|
||||
for (i=0 ; i<numlines ; i++)
|
||||
for (i = 0; i < numlines; i++)
|
||||
{
|
||||
for (j=0 ; j<numchars ; j++)
|
||||
for (j = 0; j < numchars; j++)
|
||||
{
|
||||
con.text[(con.totallines - 1 - i) * con.linewidth + j] =
|
||||
tbuf[((con.current - i + oldtotallines) %
|
||||
oldtotallines) * oldwidth + j];
|
||||
tbuf[((con.current - i + oldtotallines) % oldtotallines) * oldwidth + j];
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -272,23 +211,29 @@ Con_Init
|
|||
*/
|
||||
void Con_Init (void)
|
||||
{
|
||||
con.linewidth = -1;
|
||||
int i;
|
||||
|
||||
Con_CheckResize ();
|
||||
|
||||
MsgDev(D_INFO, "Console initialized.\n");
|
||||
Con_CheckResize();
|
||||
|
||||
// register our commands
|
||||
con_notifytime = Cvar_Get ("con_notifytime", "3", 0);
|
||||
con_speed = Cvar_Get ("con_speed", "3", 0);
|
||||
|
||||
Field_Clear( &g_consoleField );
|
||||
g_consoleField.widthInChars = g_console_field_width;
|
||||
for ( i = 0 ; i < COMMAND_HISTORY ; i++ )
|
||||
{
|
||||
Field_Clear( &historyEditLines[i] );
|
||||
historyEditLines[i].widthInChars = g_console_field_width;
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
||||
Cmd_AddCommand ("togglechat", Con_ToggleChat_f);
|
||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
||||
Cmd_AddCommand ("clear", Con_Clear_f);
|
||||
Cmd_AddCommand ("condump", Con_Dump_f);
|
||||
con.initialized = true;
|
||||
MsgDev(D_INFO, "Console initialized.\n");
|
||||
}
|
||||
|
||||
|
||||
|
@ -317,7 +262,7 @@ void Con_Linefeed (bool skipnotify)
|
|||
|
||||
/*
|
||||
================
|
||||
CL_ConsolePrint
|
||||
Con_Print
|
||||
|
||||
Handles cursor positioning, line wrapping, etc
|
||||
All console printing must go through this in order to be logged to disk
|
||||
|
@ -416,14 +361,12 @@ void Con_DrawInput (void)
|
|||
{
|
||||
int y;
|
||||
|
||||
if (cls.key_dest == key_menu) return;
|
||||
if (cls.key_dest != key_console && cls.state == ca_active)
|
||||
return; // don't draw anything (always draw if not active)
|
||||
if (cls.key_dest != key_console) return; // don't draw anything (always draw if not active)
|
||||
|
||||
y = con.vislines - ( SMALLCHAR_HEIGHT * 2 );
|
||||
re->SetColor( con.color );
|
||||
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, '>' );
|
||||
Field_Draw( &g_consoleField, con.xadjust + 2 * SMALLCHAR_WIDTH, y, SCREEN_WIDTH - 3 * SMALLCHAR_WIDTH, true );
|
||||
SCR_DrawSmallChar( con.xadjust + 1 * SMALLCHAR_WIDTH, y, '>' );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -446,7 +389,7 @@ void Con_DrawNotify (void)
|
|||
re->SetColor( g_color_table[currentColor] );
|
||||
|
||||
v = 0;
|
||||
for (i = con.current-NUM_CON_TIMES + 1; i <= con.current; i++)
|
||||
for (i = con.current - NUM_CON_TIMES + 1; i <= con.current; i++)
|
||||
{
|
||||
if (i < 0) continue;
|
||||
time = con.times[i % NUM_CON_TIMES];
|
||||
|
@ -517,7 +460,7 @@ void Con_DrawSolidConsole (float frac)
|
|||
// draw the background
|
||||
y = frac * SCREEN_HEIGHT - 2;
|
||||
if ( y < 1 ) y = 0;
|
||||
else SCR_DrawPic( 0, -SCREEN_HEIGHT + lines, SCREEN_WIDTH, SCREEN_HEIGHT, "background/conback" );
|
||||
else SCR_DrawPic( 0, y - SCREEN_HEIGHT, SCREEN_WIDTH, SCREEN_HEIGHT, "background/conback" );
|
||||
|
||||
Vector4Set( color, 1, 0, 0, 1 );
|
||||
SCR_FillRect( 0, y, SCREEN_WIDTH, 2, color );
|
||||
|
@ -564,10 +507,10 @@ void Con_DrawSolidConsole (float frac)
|
|||
|
||||
for (x = 0; x < con.linewidth; x++)
|
||||
{
|
||||
if((text[x] & 0xff ) == ' ')continue;
|
||||
if(((text[x]>>8)&7 ) != currentColor )
|
||||
if((text[x] & 0xff ) == ' ') continue;
|
||||
if(((text[x]>>8) & 7 ) != currentColor )
|
||||
{
|
||||
currentColor = (text[x]>>8)&7;
|
||||
currentColor = (text[x]>>8) & 7;
|
||||
re->SetColor(g_color_table[currentColor]);
|
||||
}
|
||||
SCR_DrawSmallChar( con.xadjust + (x+1) * SMALLCHAR_WIDTH, y, text[x] & 0xff );
|
||||
|
@ -609,6 +552,7 @@ void Con_DrawConsole( void )
|
|||
if(cls.key_dest != key_menu)
|
||||
{
|
||||
Con_DrawSolidConsole( 1.0 );
|
||||
cls.key_dest = key_console;
|
||||
}
|
||||
break;
|
||||
case ca_active:
|
||||
|
|
|
@ -30,8 +30,8 @@ void SCR_AdjustSize( float *x, float *y, float *w, float *h )
|
|||
float yscale;
|
||||
|
||||
// scale for screen sizes
|
||||
xscale = viddef.width / SCREEN_WIDTH;
|
||||
yscale = viddef.height / SCREEN_HEIGHT;
|
||||
xscale = viddef.width / 640.0f;
|
||||
yscale = viddef.height / 480.0f;
|
||||
|
||||
if(x) *x *= xscale;
|
||||
if(y) *y *= yscale;
|
||||
|
|
|
@ -650,19 +650,6 @@ extern vec3_t bytedirs[NUMVERTEXNORMALS];
|
|||
/*
|
||||
==============================================================
|
||||
|
||||
NON-PORTABLE SYSTEM SERVICES
|
||||
|
||||
==============================================================
|
||||
*/
|
||||
void Sys_Print(const char *pMsg);
|
||||
char *Sys_ConsoleInput( void );
|
||||
void Sys_SendKeyEvents (void);
|
||||
void Sys_Quit (void);
|
||||
char *Sys_GetClipboardData( void );
|
||||
|
||||
/*
|
||||
==============================================================
|
||||
|
||||
CLIENT / SERVER SYSTEMS
|
||||
|
||||
==============================================================
|
||||
|
|
|
@ -73,7 +73,7 @@ void Cbuf_AddText(const char *text)
|
|||
{
|
||||
int l;
|
||||
|
||||
l = strlen (text);
|
||||
l = strlen(text);
|
||||
if (cmd_text.cursize + l >= cmd_text.maxsize)
|
||||
{
|
||||
MsgDev(D_WARN, "Cbuf_AddText: overflow\n");
|
||||
|
@ -617,7 +617,7 @@ void Cmd_List_f (void)
|
|||
|
||||
for (cmd = cmd_functions; cmd; cmd = cmd->next)
|
||||
{
|
||||
if (match && !COM_Filter(match, cmd->name, false))
|
||||
if (match && !Com_Filter(match, cmd->name, false))
|
||||
continue;
|
||||
Msg("%s\n", cmd->name);
|
||||
i++;
|
||||
|
@ -625,40 +625,6 @@ void Cmd_List_f (void)
|
|||
Msg("%i commands\n", i);
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CMD_CheckParm
|
||||
|
||||
Returns the position (1 to argc-1) in the program's argument list
|
||||
where the given parameter apears, or 0 if not present
|
||||
================
|
||||
*/
|
||||
int Cmd_CheckParm (const char *parm)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 1; i < fs_argc; i++ )
|
||||
{
|
||||
// NEXTSTEP sometimes clears appkit vars.
|
||||
if (!fs_argv[i]) continue;
|
||||
if (!stricmp (parm, fs_argv[i])) return i;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
bool _Cmd_GetParmFromCmdLine( char *parm, char *out, size_t outsize )
|
||||
{
|
||||
int argc = Cmd_CheckParm( parm );
|
||||
|
||||
if(!argc) return false;
|
||||
if(!out) return false;
|
||||
if(!fs_argv[argc + 1]) return false;
|
||||
|
||||
strncpy( out, fs_argv[argc + 1], outsize );
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Cmd_Init
|
||||
|
@ -678,8 +644,8 @@ void Cmd_Init( int argc, char **argv )
|
|||
Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f );
|
||||
|
||||
// determine debug and developer mode
|
||||
if (Cmd_CheckParm ("-debug")) host.debug = true;
|
||||
if(Cmd_GetParmFromCmdLine("-dev", dev_level ))
|
||||
if(FS_CheckParm ("-debug")) host.debug = true;
|
||||
if(FS_GetParmFromCmdLine("-dev", dev_level ))
|
||||
host.developer = atoi(dev_level);
|
||||
}
|
||||
|
||||
|
|
|
@ -263,7 +263,7 @@ void Com_DPrintf (int level, char *fmt, ...)
|
|||
switch(level)
|
||||
{
|
||||
case D_INFO:
|
||||
Com_Print(va("^6%s", msg));
|
||||
Con_Print( msg );
|
||||
break;
|
||||
case D_WARN:
|
||||
Com_Print(va("^3Warning:^7 %s", msg));
|
||||
|
@ -300,4 +300,199 @@ void Com_DWarnf (char *fmt, ...)
|
|||
va_end (argptr);
|
||||
|
||||
Com_Print(va("^3Warning:^7 %s", msg));
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// INFOSTRING STUFF
|
||||
//=======================================================================
|
||||
/*
|
||||
===============
|
||||
Info_Print
|
||||
|
||||
printing current key-value pair
|
||||
===============
|
||||
*/
|
||||
void Info_Print (char *s)
|
||||
{
|
||||
char key[512];
|
||||
char value[512];
|
||||
char *o;
|
||||
int l;
|
||||
|
||||
if (*s == '\\') s++;
|
||||
|
||||
while (*s)
|
||||
{
|
||||
o = key;
|
||||
while (*s && *s != '\\') *o++ = *s++;
|
||||
|
||||
l = o - key;
|
||||
if (l < 20)
|
||||
{
|
||||
memset (o, ' ', 20-l);
|
||||
key[20] = 0;
|
||||
}
|
||||
else *o = 0;
|
||||
Msg ("%s", key);
|
||||
|
||||
if (!*s)
|
||||
{
|
||||
Msg ("MISSING VALUE\n");
|
||||
return;
|
||||
}
|
||||
|
||||
o = value;
|
||||
s++;
|
||||
while (*s && *s != '\\') *o++ = *s++;
|
||||
*o = 0;
|
||||
|
||||
if (*s) s++;
|
||||
Msg ("%s\n", value);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
Info_ValueForKey
|
||||
|
||||
Searches the string for the given
|
||||
key and returns the associated value, or an empty string.
|
||||
===============
|
||||
*/
|
||||
char *Info_ValueForKey (char *s, char *key)
|
||||
{
|
||||
char pkey[512];
|
||||
static char value[2][512]; // use two buffers so compares work without stomping on each other
|
||||
static int valueindex;
|
||||
char *o;
|
||||
|
||||
valueindex ^= 1;
|
||||
if (*s == '\\') s++;
|
||||
while (1)
|
||||
{
|
||||
o = pkey;
|
||||
while (*s != '\\')
|
||||
{
|
||||
if (!*s) return "";
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
s++;
|
||||
|
||||
o = value[valueindex];
|
||||
|
||||
while (*s != '\\' && *s)
|
||||
{
|
||||
if (!*s) return "";
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey) ) return value[valueindex];
|
||||
if (!*s) return "";
|
||||
s++;
|
||||
}
|
||||
}
|
||||
|
||||
void Info_RemoveKey (char *s, char *key)
|
||||
{
|
||||
char *start;
|
||||
char pkey[512];
|
||||
char value[512];
|
||||
char *o;
|
||||
|
||||
if (strstr (key, "\\")) return;
|
||||
|
||||
while (1)
|
||||
{
|
||||
start = s;
|
||||
if (*s == '\\') s++;
|
||||
o = pkey;
|
||||
while (*s != '\\')
|
||||
{
|
||||
if (!*s) return;
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
s++;
|
||||
|
||||
o = value;
|
||||
while (*s != '\\' && *s)
|
||||
{
|
||||
if (!*s) return;
|
||||
*o++ = *s++;
|
||||
}
|
||||
*o = 0;
|
||||
|
||||
if (!strcmp (key, pkey) )
|
||||
{
|
||||
strcpy (start, s); // remove this part
|
||||
return;
|
||||
}
|
||||
if (!*s) return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Info_Validate
|
||||
|
||||
Some characters are illegal in info strings because they
|
||||
can mess up the server's parsing
|
||||
==================
|
||||
*/
|
||||
bool Info_Validate (char *s)
|
||||
{
|
||||
if (strstr (s, "\"")) return false;
|
||||
if (strstr (s, ";")) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Info_SetValueForKey (char *s, char *key, char *value)
|
||||
{
|
||||
char newi[MAX_INFO_STRING], *v;
|
||||
int c, maxsize = MAX_INFO_STRING;
|
||||
|
||||
if (strstr (key, "\\") || strstr (value, "\\") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a \\\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (strstr (key, ";") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a semicolon\n");
|
||||
return;
|
||||
}
|
||||
if (strstr (key, "\"") || strstr (value, "\"") )
|
||||
{
|
||||
Msg ("Can't use keys or values with a \"\n");
|
||||
return;
|
||||
}
|
||||
if (strlen(key) > MAX_INFO_KEY - 1 || strlen(value) > MAX_INFO_KEY-1)
|
||||
{
|
||||
Msg ("Keys and values must be < 64 characters.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
Info_RemoveKey (s, key);
|
||||
if (!value || !strlen(value)) return;
|
||||
sprintf (newi, "\\%s\\%s", key, value);
|
||||
|
||||
if (strlen(newi) + strlen(s) > maxsize)
|
||||
{
|
||||
Msg ("Info string length exceeded\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// only copy ascii values
|
||||
s += strlen(s);
|
||||
v = newi;
|
||||
while (*v)
|
||||
{
|
||||
c = *v++;
|
||||
c &= 127; // strip high bits
|
||||
if (c >= 32 && c < 127) *s++ = c;
|
||||
}
|
||||
*s = 0;
|
||||
}
|
|
@ -676,7 +676,7 @@ void Cvar_List_f( void )
|
|||
|
||||
for (var = cvar_vars; var; var = var->next, i++)
|
||||
{
|
||||
if (match && !COM_Filter(match, var->name, false))
|
||||
if (match && !Com_Filter(match, var->name, false))
|
||||
continue;
|
||||
|
||||
if (var->flags & CVAR_SERVERINFO) Msg("S");
|
||||
|
|
|
@ -2049,7 +2049,7 @@ void StartServerActionFunc( void *self )
|
|||
bool Menu_CreateMapsList( void )
|
||||
{
|
||||
char *buffer;
|
||||
search_t *t = FS_Search( "maps/*.bsp" );
|
||||
search_t *t = FS_Search( "maps/*.bsp", false );
|
||||
int i, k, result = 0;
|
||||
|
||||
if(!t) return result;
|
||||
|
@ -2096,13 +2096,12 @@ bool Menu_CreateMapsList( void )
|
|||
if(entities)
|
||||
{
|
||||
bool have_title = false;
|
||||
char *com_token;
|
||||
|
||||
data = entities;
|
||||
while( 1 )
|
||||
{
|
||||
int l;
|
||||
com_token = COM_Parse(&data);
|
||||
Com_ParseToken(&data);
|
||||
|
||||
if (!com_token) break;
|
||||
if (com_token[0] == '{') continue;
|
||||
|
@ -2113,7 +2112,7 @@ bool Menu_CreateMapsList( void )
|
|||
keyname[l] = com_token[k+l];
|
||||
keyname[l] = 0;
|
||||
|
||||
com_token = COM_Parse(&data);
|
||||
Com_ParseToken(&data);
|
||||
if (!com_token) break;
|
||||
|
||||
if (!strcmp(keyname, "message") && !have_title)
|
||||
|
@ -2204,11 +2203,11 @@ void StartServer_MenuInit( void )
|
|||
char scratch[200];
|
||||
int j, l;
|
||||
|
||||
strcpy( shortname, COM_Parse( &s ));
|
||||
strcpy( shortname, Com_ParseToken( &s ));
|
||||
l = strlen(shortname);
|
||||
for (j=0 ; j<l ; j++)
|
||||
shortname[j] = toupper(shortname[j]);
|
||||
strcpy( longname, COM_Parse( &s ));
|
||||
strcpy( longname, Com_ParseToken( &s ));
|
||||
sprintf( scratch, "%s\n%s", longname, shortname );
|
||||
|
||||
mapnames[i] = Z_Malloc( strlen( scratch ) + 1 );
|
||||
|
@ -2966,7 +2965,7 @@ static bool PlayerConfig_ScanDirectories( void )
|
|||
|
||||
s_numplayermodels = 0;
|
||||
|
||||
search = FS_Search( "models/players/*" );
|
||||
search = FS_Search( "models/players/*", false );
|
||||
|
||||
if ( !search ) return false;
|
||||
|
||||
|
|
|
@ -1737,16 +1737,16 @@ void VM_tokenize (void)
|
|||
num_tokens = 0;
|
||||
pos = 0;
|
||||
|
||||
while(COM_Parse(&p))
|
||||
while(Com_ParseToken(&p))
|
||||
{
|
||||
size_t tokenlen;
|
||||
if (num_tokens >= (int)(sizeof(tokens)/sizeof(tokens[0])))
|
||||
break;
|
||||
tokenlen = strlen(COM_Token) + 1;
|
||||
tokenlen = strlen(com_token) + 1;
|
||||
if (pos + tokenlen > sizeof(tokenbuf))
|
||||
break;
|
||||
tokens[num_tokens++] = tokenbuf + pos;
|
||||
Mem_Copy(tokenbuf + pos, COM_Token, tokenlen);
|
||||
Mem_Copy(tokenbuf + pos, com_token, tokenlen);
|
||||
pos += tokenlen;
|
||||
}
|
||||
|
||||
|
@ -1907,7 +1907,7 @@ void VM_parseentitydata(void)
|
|||
data = PRVM_G_STRING(OFS_PARM1);
|
||||
|
||||
// parse the opening brace
|
||||
if (!COM_Parse(&data) || COM_Token[0] != '{' )
|
||||
if (!Com_ParseToken(&data) || com_token[0] != '{' )
|
||||
PRVM_ERROR ("VM_parseentitydata: %s: Couldn't parse entity data:\n%s", PRVM_NAME, data );
|
||||
|
||||
PRVM_ED_ParseEdict (data, ent);
|
||||
|
@ -2016,7 +2016,7 @@ void VM_search_begin(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if(!(prog->opensearches[handle] = FS_Search(pattern)))
|
||||
if(!(prog->opensearches[handle] = FS_Search(pattern, false)))
|
||||
PRVM_G_FLOAT(OFS_RETURN) = -1;
|
||||
else
|
||||
PRVM_G_FLOAT(OFS_RETURN) = handle;
|
||||
|
|
|
@ -870,18 +870,18 @@ void PRVM_ED_ParseGlobals (const char *data)
|
|||
while (1)
|
||||
{
|
||||
// parse key
|
||||
if (!COM_Parse(&data))
|
||||
if (!Com_ParseToken(&data))
|
||||
PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
|
||||
if (COM_Token[0] == '}')
|
||||
if (com_token[0] == '}')
|
||||
break;
|
||||
|
||||
strncpy (keyname, COM_Token, sizeof(keyname));
|
||||
strncpy (keyname, com_token, sizeof(keyname));
|
||||
|
||||
// parse value
|
||||
if (!COM_Parse(&data))
|
||||
if (!Com_ParseToken(&data))
|
||||
PRVM_ERROR ("PRVM_ED_ParseGlobals: EOF without closing brace");
|
||||
|
||||
if (COM_Token[0] == '}')
|
||||
if (com_token[0] == '}')
|
||||
PRVM_ERROR ("PRVM_ED_ParseGlobals: closing brace without data");
|
||||
|
||||
key = PRVM_ED_FindGlobal (keyname);
|
||||
|
@ -891,7 +891,7 @@ void PRVM_ED_ParseGlobals (const char *data)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (!PRVM_ED_ParseEpair(NULL, key, COM_Token))
|
||||
if (!PRVM_ED_ParseEpair(NULL, key, com_token))
|
||||
PRVM_ERROR ("PRVM_ED_ParseGlobals: parse error");
|
||||
}
|
||||
}
|
||||
|
@ -1058,23 +1058,23 @@ const char *PRVM_ED_ParseEdict (const char *data, edict_t *ent)
|
|||
while (1)
|
||||
{
|
||||
// parse key
|
||||
if (!COM_Parse(&data))
|
||||
if (!Com_ParseToken(&data))
|
||||
PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
|
||||
|
||||
newline = (COM_Token[0] == '}') ? true : false;
|
||||
if(!newline) MsgDev(D_NOTE, "Key: \"%s\"", COM_Token);
|
||||
newline = (com_token[0] == '}') ? true : false;
|
||||
if(!newline) MsgDev(D_NOTE, "Key: \"%s\"", com_token);
|
||||
else break;
|
||||
|
||||
// anglehack is to allow QuakeEd to write single scalar angles
|
||||
// and allow them to be turned into vectors. (FIXME...)
|
||||
if (!strcmp(COM_Token, "angle"))
|
||||
if (!strcmp(com_token, "angle"))
|
||||
{
|
||||
strncpy (COM_Token, "angles", MAX_QPATH);
|
||||
strncpy (com_token, "angles", MAX_QPATH);
|
||||
anglehack = true;
|
||||
}
|
||||
else anglehack = false;
|
||||
|
||||
strncpy (keyname, COM_Token, sizeof(keyname));
|
||||
strncpy (keyname, com_token, sizeof(keyname));
|
||||
|
||||
// another hack to fix keynames with trailing spaces
|
||||
n = strlen(keyname);
|
||||
|
@ -1085,11 +1085,11 @@ const char *PRVM_ED_ParseEdict (const char *data, edict_t *ent)
|
|||
}
|
||||
|
||||
// parse value
|
||||
if (!COM_Parse(&data))
|
||||
if (!Com_ParseToken(&data))
|
||||
PRVM_ERROR ("PRVM_ED_ParseEdict: EOF without closing brace");
|
||||
MsgDev(D_NOTE, " \"%s\"\n", COM_Token);
|
||||
MsgDev(D_NOTE, " \"%s\"\n", com_token);
|
||||
|
||||
if (COM_Token[0] == '}')
|
||||
if (com_token[0] == '}')
|
||||
PRVM_ERROR ("PRVM_ED_ParseEdict: closing brace without data");
|
||||
|
||||
init = true;
|
||||
|
@ -1113,11 +1113,11 @@ const char *PRVM_ED_ParseEdict (const char *data, edict_t *ent)
|
|||
{
|
||||
char temp[32];
|
||||
|
||||
strncpy (temp, COM_Token, sizeof(temp));
|
||||
sprintf (COM_Token, "0 %s 0", temp);
|
||||
strncpy (temp, com_token, sizeof(temp));
|
||||
sprintf (com_token, "0 %s 0", temp);
|
||||
}
|
||||
|
||||
if (!PRVM_ED_ParseEpair(ent, key, COM_Token))
|
||||
if (!PRVM_ED_ParseEpair(ent, key, com_token))
|
||||
PRVM_ERROR ("PRVM_ED_ParseEdict: parse error");
|
||||
}
|
||||
|
||||
|
@ -1158,9 +1158,9 @@ void PRVM_ED_LoadFromFile (const char *data)
|
|||
while (1)
|
||||
{
|
||||
// parse the opening brace
|
||||
if (!COM_Parse(&data)) break;
|
||||
if (COM_Token[0] != '{')
|
||||
PRVM_ERROR ("PRVM_ED_LoadFromFile: %s: found %s when expecting {", PRVM_NAME, COM_Token);
|
||||
if (!Com_ParseToken(&data)) break;
|
||||
if (com_token[0] != '{')
|
||||
PRVM_ERROR ("PRVM_ED_LoadFromFile: %s: found %s when expecting {", PRVM_NAME, com_token);
|
||||
|
||||
// CHANGED: this is not conform to PR_LoadFromFile
|
||||
if(prog->loadintoworld)
|
||||
|
@ -1236,7 +1236,7 @@ void PRVM_ResetProg()
|
|||
{
|
||||
PRVM_GCALL(reset_cmd)();
|
||||
Mem_FreePool(&prog->progs_mempool);
|
||||
memset(prog,0,sizeof(prvm_prog_t));
|
||||
memset(prog, 0, sizeof(prvm_prog_t));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1333,7 +1333,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
break;
|
||||
}
|
||||
|
||||
//try to recognize progs.dat by crc
|
||||
// try to recognize progs.dat by crc
|
||||
switch(prog->progs->crc)
|
||||
{
|
||||
case PROG_CRC_SERVER:
|
||||
|
@ -1373,7 +1373,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked statements: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->statements)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->statements)+1), complen, &s, len );
|
||||
prog->statements = (dstatement16_t *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked defs: len %d, comp len %d\n", len, complen);
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->globaldefs)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->globaldefs)+1), complen, &s, len );
|
||||
prog->globaldefs = (ddef16_t *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1415,7 +1415,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked fields: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)infielddefs)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)infielddefs)+1), complen, &s, len );
|
||||
infielddefs = (ddef16_t *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1427,7 +1427,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked functions: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)dfunctions)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)dfunctions)+1), complen, &s, len );
|
||||
dfunctions = (dfunction_t *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1439,7 +1439,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked strings: count %d, len %d, comp len %d\n", prog->progs->numstrings, len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->strings)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->strings)+1), complen, &s, len );
|
||||
prog->strings = (char *)s;
|
||||
|
||||
prog->progs->ofs_strings += 4;
|
||||
|
@ -1453,7 +1453,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked globals: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->globals.gp)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->globals.gp)+1), complen, &s, len );
|
||||
prog->globals.gp = (float *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1465,7 +1465,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked linenums: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT(complen, len, 2, (char *)(((int *)prog->linenums)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->linenums)+1), complen, &s, len );
|
||||
prog->linenums = (int *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1477,7 +1477,7 @@ void PRVM_LoadProgs (const char *filename, int numedfunc, char **ed_func, int nu
|
|||
|
||||
MsgDev(D_NOTE, "Unpacked types: len %d, comp len %d\n", len, complen );
|
||||
s = Mem_Alloc(prog->progs_mempool, len ); // alloc memory for inflate block
|
||||
Com->Compile.DecryptDAT( complen, len, 2, (char *)(((int *)prog->types)+1), &s);
|
||||
VFS_Unpack((char *)(((int *)prog->types)+1), complen, &s, len );
|
||||
prog->types = (type_t *)s;
|
||||
filesize += len - complen - sizeof(int); //merge filesize
|
||||
}
|
||||
|
@ -1947,7 +1947,7 @@ void VM_Error (const char *fmt, ...)
|
|||
vsprintf (msg, fmt, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
Host_Error ("Prvm error: %s", msg);
|
||||
Msg ("Prvm error: %s", msg);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
110
engine/engine.h
110
engine/engine.h
|
@ -20,6 +20,7 @@
|
|||
#include "basetypes.h"
|
||||
#include "basemath.h"
|
||||
#include <ref_system.h>
|
||||
#include <ref_stdlib.h>
|
||||
#include "vprogs.h"
|
||||
#include "const.h"
|
||||
#include "common.h"
|
||||
|
@ -27,7 +28,6 @@
|
|||
#include "client.h"
|
||||
|
||||
extern stdlib_api_t std;
|
||||
extern common_exp_t *Com;
|
||||
extern physic_exp_t *Phys;
|
||||
extern byte *zonepool;
|
||||
|
||||
|
@ -42,13 +42,6 @@ typedef enum
|
|||
|
||||
} host_state;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
HOST_OFFLINE, // host not running
|
||||
HOST_NORMAL, // normal mode
|
||||
HOST_DEDICATED, // dedicated mode
|
||||
} host_mode;
|
||||
|
||||
typedef struct host_redirect_s
|
||||
{
|
||||
int target;
|
||||
|
@ -61,7 +54,7 @@ typedef struct host_redirect_s
|
|||
typedef struct host_parm_s
|
||||
{
|
||||
host_state state; // global host state
|
||||
host_mode type; // running at
|
||||
uint type; // running at
|
||||
|
||||
bool debug; // show all warnings mode
|
||||
int developer; // show all developer's message
|
||||
|
@ -83,9 +76,6 @@ typedef struct host_parm_s
|
|||
|
||||
} host_parm_t;
|
||||
|
||||
bool _GetParmFromCmdLine( char *parm, char *out, size_t size );
|
||||
#define GetParmFromCmdLine( parm, out ) _GetParmFromCmdLine( parm, out, sizeof(out))
|
||||
|
||||
stdlib_api_t Host_GetStdio( bool crash_on_error );
|
||||
|
||||
/*
|
||||
|
@ -93,92 +83,10 @@ stdlib_api_t Host_GetStdio( bool crash_on_error );
|
|||
memory manager
|
||||
===========================================
|
||||
*/
|
||||
//z_malloc-free
|
||||
// z_malloc-free
|
||||
#define Z_Malloc(size) Mem_Alloc(zonepool, size)
|
||||
#define Z_Free(data) Mem_Free(data)
|
||||
|
||||
//malloc-free
|
||||
#define Mem_Alloc(pool,size) std.malloc(pool, size, __FILE__, __LINE__)
|
||||
#define Mem_Realloc(pool, mem, size) std.realloc(pool, mem, size, __FILE__, __LINE__)
|
||||
#define Mem_Free(mem) std.free(mem, __FILE__, __LINE__)
|
||||
|
||||
//Hunk_AllocName
|
||||
#define Mem_AllocPool(name) std.mallocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) std.freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) std.clearpool(pool, __FILE__, __LINE__)
|
||||
|
||||
#define Mem_Copy(dest, src, size) std.memcpy(dest, src, size, __FILE__, __LINE__)
|
||||
|
||||
/*
|
||||
===========================================
|
||||
filesystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define FS_AddGameHierarchy std.AddGameHierarchy
|
||||
#define FS_LoadGameInfo std.LoadGameInfo
|
||||
#define FS_InitRootDir std.InitRootDir
|
||||
#define FS_LoadFile(name, size) std.Fs.LoadFile(name, size)
|
||||
#define FS_LoadImage(name, data, size) std.Fs.LoadImage(name, data, size)
|
||||
#define FS_Search(path) std.Fs.Search( path, true )
|
||||
#define FS_WriteFile(name, data, size) std.Fs.WriteFile(name, data, size )
|
||||
#define FS_Open( path, mode ) std.Fs.Open( path, mode )
|
||||
#define FS_Read( file, buffer, size ) std.Fs.Read( file, buffer, size )
|
||||
#define FS_Write( file, buffer, size ) std.Fs.Write( file, buffer, size )
|
||||
#define FS_StripExtension( path ) std.Fs.StripExtension( path )
|
||||
#define FS_DefaultExtension( path, ext ) std.Fs.DefaultExtension( path, ext )
|
||||
#define FS_FileExtension( ext ) std.Fs.FileExtension( ext )
|
||||
#define FS_FileExists( file ) std.Fs.FileExists( file )
|
||||
#define FS_Close( file ) std.Fs.Close( file )
|
||||
#define FS_FileBase( x, y ) std.Fs.FileBase( x, y )
|
||||
#define FS_Find( x ) std.Fs.Search( x, false )
|
||||
#define FS_Printf std.Fs.Printf
|
||||
#define FS_Print std.Fs.Print
|
||||
#define FS_Seek std.Fs.Seek
|
||||
#define FS_Tell std.Fs.Tell
|
||||
#define FS_Gets std.Fs.Gets
|
||||
char *FS_Gamedir( void );
|
||||
|
||||
/*
|
||||
===========================================
|
||||
scriptsystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define COM_Parse(data) std.Script.ParseToken(data)
|
||||
#define COM_Token std.Script.Token
|
||||
#define COM_Filter std.Script.FilterToken
|
||||
|
||||
#define COM_LoadScript std.Script.Load
|
||||
#define COM_IncludeScript std.Script.Include
|
||||
#define COM_ResetScript std.Script.Reset
|
||||
#define COM_GetToken std.Script.GetToken
|
||||
#define COM_TryToken std.Script.TryToken
|
||||
#define COM_FreeToken std.Script.FreeToken
|
||||
#define COM_SkipToken std.Script.SkipToken
|
||||
#define COM_MatchToken std.Script.MatchToken
|
||||
|
||||
#define CRC_Init std.crc_init
|
||||
#define CRC_Block std.crc_block
|
||||
#define CRC_ProcessByte std.crc_process
|
||||
|
||||
/*
|
||||
===========================================
|
||||
infostring manager
|
||||
===========================================
|
||||
*/
|
||||
#define Info_Print(x) Com->Info.Print
|
||||
#define Info_Validate(x) Com->Info.Validate(x)
|
||||
#define Info_RemoveKey(x, y) Com->Info.RemoveKey(x,y)
|
||||
#define Info_ValueForKey(x,y) Com->Info.ValueForKey(x,y)
|
||||
#define Info_SetValueForKey(x,y,z) Com->Info.SetValueForKey(x,y,z)
|
||||
|
||||
/*
|
||||
===========================================
|
||||
System Timer
|
||||
===========================================
|
||||
*/
|
||||
double Sys_DoubleTime( void );
|
||||
#define GI Com->GameInfo()
|
||||
|
||||
/*
|
||||
===========================================
|
||||
System Events
|
||||
|
@ -188,14 +96,6 @@ System Events
|
|||
#define Msg Com_Printf
|
||||
#define MsgDev Com_DPrintf
|
||||
#define MsgWarn Com_DWarnf
|
||||
#define Sys_LoadLibrary std.LoadLibrary
|
||||
#define Sys_FreeLibrary std.FreeLibrary
|
||||
#define Sys_Sleep std.sleep
|
||||
#define Sys_Print std.print
|
||||
#define Sys_Quit std.exit
|
||||
#define Sys_ConsoleInput std.input
|
||||
#define copystring std.stralloc
|
||||
#define va std.va
|
||||
|
||||
/*
|
||||
===========================================
|
||||
|
@ -203,7 +103,7 @@ Host Interface
|
|||
===========================================
|
||||
*/
|
||||
extern host_parm_t host;
|
||||
void Host_Init ( char *funcname, int argc, char **argv );
|
||||
void Host_Init ( uint funcname, int argc, char **argv );
|
||||
void Host_Main ( void );
|
||||
void Host_Free ( void );
|
||||
void Host_Error( const char *error, ... );
|
||||
|
@ -218,7 +118,9 @@ void Host_Error_f( void );
|
|||
System utilites
|
||||
===========================================
|
||||
*/
|
||||
double Sys_DoubleTime( void );
|
||||
void Sys_Error( const char *msg, ... );
|
||||
void Sys_SendKeyEvents( void );
|
||||
|
||||
//
|
||||
// in_win.c
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <dsound.h>
|
||||
#include "engine.h"
|
||||
|
||||
common_exp_t *Com; // fundamental callbacks
|
||||
physic_exp_t *Phys;
|
||||
host_parm_t host; // host parms
|
||||
stdlib_api_t std;
|
||||
|
@ -22,7 +21,6 @@ void Key_Init (void);
|
|||
void SCR_EndLoadingPlaque (void);
|
||||
|
||||
HINSTANCE global_hInstance;
|
||||
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(common_exp_t) };
|
||||
dll_info_t physic_dll = { "physic.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(physic_exp_t) };
|
||||
|
||||
cvar_t *timescale;
|
||||
|
@ -46,18 +44,8 @@ stdlib_api_t Host_GetStdio( bool crash_on_error )
|
|||
return io;
|
||||
}
|
||||
|
||||
void Host_InitCommon( char *funcname, int argc, char **argv )
|
||||
void Host_InitCommon( uint funcname, int argc, char **argv )
|
||||
{
|
||||
common_t CreateCom;
|
||||
stdlib_api_t io = Host_GetStdio( true );
|
||||
|
||||
Sys_LoadLibrary( &common_dll );
|
||||
|
||||
CreateCom = (void *)common_dll.main;
|
||||
Com = CreateCom( &io );
|
||||
|
||||
Com->Init( argc, argv );
|
||||
|
||||
// TODO: init basedir here
|
||||
FS_LoadGameInfo("gameinfo.txt");
|
||||
zonepool = Mem_AllocPool("Zone Engine");
|
||||
|
@ -65,29 +53,23 @@ void Host_InitCommon( char *funcname, int argc, char **argv )
|
|||
|
||||
void Host_FreeCommon( void )
|
||||
{
|
||||
if(common_dll.link)
|
||||
{
|
||||
Mem_FreePool( &zonepool );
|
||||
Com->Shutdown();
|
||||
}
|
||||
Sys_FreeLibrary( &common_dll );
|
||||
Mem_FreePool( &zonepool );
|
||||
}
|
||||
|
||||
void Host_InitPhysic( void )
|
||||
{
|
||||
static physic_imp_t pi;
|
||||
physic_t CreatePhys;
|
||||
|
||||
pi.Compile = Com->Compile;
|
||||
pi.Stdio = Host_GetStdio( false );
|
||||
launch_t CreatePhys;
|
||||
stdlib_api_t io = Host_GetStdio( false );
|
||||
|
||||
// phys callback
|
||||
pi.api_size = sizeof(physic_imp_t);
|
||||
pi.Transform = SV_Transform;
|
||||
|
||||
Sys_LoadLibrary( &physic_dll );
|
||||
|
||||
CreatePhys = (void *)physic_dll.main;
|
||||
Phys = CreatePhys( &pi );
|
||||
Phys = CreatePhys( &io, &pi );
|
||||
|
||||
Phys->Init();
|
||||
}
|
||||
|
@ -118,17 +100,14 @@ void Host_AbortCurrentFrame( void )
|
|||
Host_Init
|
||||
=================
|
||||
*/
|
||||
void Host_Init (char *funcname, int argc, char **argv)
|
||||
void Host_Init (uint funcname, int argc, char **argv)
|
||||
{
|
||||
char *s;
|
||||
|
||||
host.state = HOST_INIT; //initialzation started
|
||||
|
||||
global_hInstance = (HINSTANCE)GetModuleHandle( NULL );
|
||||
|
||||
if(!strcmp(funcname, "host_dedicated")) host.type = HOST_DEDICATED;
|
||||
else if(!strcmp(funcname, "host_shared")) host.type = HOST_NORMAL;
|
||||
else host.type = HOST_OFFLINE; // launcher can loading engine for some reasons
|
||||
host.type = funcname;
|
||||
|
||||
srand(time(NULL)); // init random generator
|
||||
|
||||
|
@ -139,8 +118,13 @@ void Host_Init (char *funcname, int argc, char **argv)
|
|||
PRVM_Init();
|
||||
|
||||
// get default configuration
|
||||
#if 1
|
||||
Cbuf_AddText("exec keys.rc\n");
|
||||
Cbuf_AddText("exec vars.rc\n");
|
||||
#else
|
||||
Cbuf_AddText("exec default.cfg\n");
|
||||
Cbuf_AddText("exec config.cfg\n");
|
||||
#endif
|
||||
Cbuf_Execute();
|
||||
|
||||
// init commands and vars
|
||||
|
@ -157,11 +141,11 @@ void Host_Init (char *funcname, int argc, char **argv)
|
|||
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_INIT);
|
||||
|
||||
if (dedicated->value) Cmd_AddCommand ("quit", Sys_Quit);
|
||||
|
||||
|
||||
NET_Init();
|
||||
Netchan_Init();
|
||||
Host_InitPhysic();
|
||||
|
||||
|
||||
SV_Init();
|
||||
CL_Init();
|
||||
|
||||
|
@ -197,7 +181,7 @@ void Host_Frame (double time)
|
|||
s = Sys_ConsoleInput ();
|
||||
if(s) Cbuf_AddText (va("%s\n",s));
|
||||
} while (s);
|
||||
Cbuf_Execute ();
|
||||
Cbuf_Execute();
|
||||
|
||||
// if at a full screen console, don't update unless needed
|
||||
if (Minimized || host.type == HOST_DEDICATED )
|
||||
|
|
|
@ -10,29 +10,6 @@
|
|||
|
||||
byte *sav_base;
|
||||
|
||||
/*
|
||||
====================
|
||||
CurTime()
|
||||
|
||||
returned a time stamp
|
||||
====================
|
||||
*/
|
||||
const char* SV_CurTime( void )
|
||||
{
|
||||
static char timestamp [128];
|
||||
time_t crt_time;
|
||||
const struct tm *crt_tm;
|
||||
char timestring [64];
|
||||
|
||||
// Build the time stamp (ex: "Apr2007-03(23.31.55)");
|
||||
time (&crt_time);
|
||||
crt_tm = localtime (&crt_time);
|
||||
strftime (timestring, sizeof (timestring), "%b%d-%Y (%H:%M)", crt_tm);
|
||||
strcpy( timestamp, timestring );
|
||||
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
void SV_AddSaveLump( dsavehdr_t *hdr, file_t *f, int lumpnum, void *data, int len )
|
||||
{
|
||||
lump_t *lump;
|
||||
|
@ -43,34 +20,6 @@ void SV_AddSaveLump( dsavehdr_t *hdr, file_t *f, int lumpnum, void *data, int le
|
|||
FS_Write(f, data, (len + 3) & ~3 );
|
||||
}
|
||||
|
||||
size_t COM_PackString( byte *buffer, int pos, char *string )
|
||||
{
|
||||
int strsize;
|
||||
|
||||
if(!buffer || !string) return 0;
|
||||
|
||||
strsize = strlen( string );
|
||||
if(strsize > MAX_QPATH) strsize = MAX_QPATH; //critical stuff
|
||||
strsize++; // get space for terminator
|
||||
|
||||
strncpy(buffer + pos, string, strsize );
|
||||
return pos + strsize;
|
||||
}
|
||||
|
||||
size_t COM_UnpackString( byte *buffer, int pos, char *string )
|
||||
{
|
||||
int strsize = 0;
|
||||
char *in;
|
||||
|
||||
if(!buffer || !string) return 0;
|
||||
in = buffer + pos;
|
||||
|
||||
do { in++, strsize++; } while(*in != '\0' && in != NULL );
|
||||
|
||||
strncpy( string, in - (strsize - 1), strsize );
|
||||
return pos + strsize;
|
||||
}
|
||||
|
||||
void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
||||
{
|
||||
cvar_t *var;
|
||||
|
@ -101,8 +50,8 @@ void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
|||
continue;
|
||||
}
|
||||
|
||||
bufsize = COM_PackString(cvbuffer, bufsize, var->name );
|
||||
bufsize = COM_PackString(cvbuffer, bufsize, var->string );
|
||||
bufsize = std.strpack(cvbuffer, bufsize, var->name, strlen(var->name));
|
||||
bufsize = std.strpack(cvbuffer, bufsize, var->string, strlen(var->name));
|
||||
}
|
||||
|
||||
SV_AddSaveLump( hdr, f, LUMP_GAMECVARS, cvbuffer, bufsize );
|
||||
|
@ -111,13 +60,14 @@ void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
|||
|
||||
void SV_AddCStrLump( dsavehdr_t *hdr, file_t *f )
|
||||
{
|
||||
int i, bufsize = 1; //null terminator
|
||||
int i, stringsize, bufsize = 1; //null terminator
|
||||
char *csbuffer = Z_Malloc( MAX_CONFIGSTRINGS * MAX_QPATH );
|
||||
|
||||
//pack the cfg string data
|
||||
for(i = 0; i < MAX_CONFIGSTRINGS; i++)
|
||||
{
|
||||
bufsize = COM_PackString(csbuffer, bufsize, sv.configstrings[i] );
|
||||
stringsize = bound(0, strlen(sv.configstrings[i]), MAX_QPATH);
|
||||
bufsize = std.strpack(csbuffer, bufsize, sv.configstrings[i], stringsize );
|
||||
}
|
||||
SV_AddSaveLump( hdr, f, LUMP_CFGSTRING, csbuffer, bufsize );
|
||||
Z_Free( csbuffer ); // free memory
|
||||
|
@ -149,7 +99,7 @@ void SV_WriteSaveFile( char *name )
|
|||
}
|
||||
|
||||
MsgDev (D_INFO, "Saving game... %s\n", name );
|
||||
sprintf (comment, "%s - %s", sv.configstrings[CS_NAME], SV_CurTime());
|
||||
sprintf (comment, "%s - %s", sv.configstrings[CS_NAME], timestamp(TIME_FULL));
|
||||
|
||||
header = (dsavehdr_t *)Z_Malloc( sizeof(dsavehdr_t));
|
||||
header->ident = LittleLong (IDSAVEHEADER);
|
||||
|
@ -196,8 +146,8 @@ void Sav_LoadCvars( lump_t *l )
|
|||
|
||||
while(pos < size)
|
||||
{
|
||||
pos = COM_UnpackString( in, pos, name );
|
||||
pos = COM_UnpackString( in, pos, string );
|
||||
pos = std.strunpack( in, pos, name );
|
||||
pos = std.strunpack( in, pos, string );
|
||||
Cvar_SetLatched(name, string);
|
||||
}
|
||||
}
|
||||
|
@ -225,13 +175,13 @@ void Sav_LoadCfgString( lump_t *l )
|
|||
//unpack the cfg string data
|
||||
for(i = 0; i < MAX_CONFIGSTRINGS; i++)
|
||||
{
|
||||
pos = COM_UnpackString( in, pos, sv.configstrings[i] );
|
||||
pos = std.strunpack( in, pos, sv.configstrings[i] );
|
||||
}
|
||||
}
|
||||
|
||||
void Sav_LoadAreaPortals( lump_t *l )
|
||||
{
|
||||
//CM_ReadPortalState
|
||||
// CM_ReadPortalState
|
||||
byte *in;
|
||||
int size;
|
||||
|
||||
|
|
|
@ -45,13 +45,6 @@ void Sys_Error( const char *error, ... )
|
|||
std.error("%s", syserror1);
|
||||
}
|
||||
|
||||
double Sys_DoubleTime( void )
|
||||
{
|
||||
// precision timer
|
||||
host.realtime = std.gettime();
|
||||
return host.realtime;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_SendKeyEvents
|
||||
|
@ -61,47 +54,18 @@ Send Key_Event calls
|
|||
*/
|
||||
void Sys_SendKeyEvents (void)
|
||||
{
|
||||
MSG msg;
|
||||
|
||||
while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE))
|
||||
{
|
||||
if (!GetMessage (&msg, NULL, 0, 0)) Sys_Quit ();
|
||||
host.sv_timer = msg.time;
|
||||
TranslateMessage (&msg);
|
||||
DispatchMessage (&msg);
|
||||
}
|
||||
// grab frame time
|
||||
host.sv_timer = Sys_GetKeyEvents();
|
||||
host.cl_timer = host.realtime * 1000;
|
||||
host.realtime = Sys_DoubleTime();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Sys_GetClipboardData
|
||||
|
||||
FIXME: move to launch.dll
|
||||
================
|
||||
*/
|
||||
char *Sys_GetClipboardData( void )
|
||||
double Sys_DoubleTime( void )
|
||||
{
|
||||
char *data = NULL;
|
||||
char *cliptext;
|
||||
|
||||
if ( OpenClipboard( NULL ) != 0 )
|
||||
{
|
||||
HANDLE hClipboardData;
|
||||
|
||||
if ( ( hClipboardData = GetClipboardData( CF_TEXT ) ) != 0 )
|
||||
{
|
||||
if ( ( cliptext = GlobalLock( hClipboardData ) ) != 0 )
|
||||
{
|
||||
data = Z_Malloc( GlobalSize( hClipboardData ) + 1 );
|
||||
strcpy( data, cliptext );
|
||||
GlobalUnlock( hClipboardData );
|
||||
}
|
||||
}
|
||||
CloseClipboard();
|
||||
}
|
||||
return data;
|
||||
// precision timer
|
||||
host.realtime = std.Com_DoubleTime();
|
||||
return host.realtime;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -110,14 +74,11 @@ DllMain
|
|||
|
||||
==================
|
||||
*/
|
||||
launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input )
|
||||
launch_exp_t DLLEXPORT *CreateAPI( stdlib_api_t *input, void *unused )
|
||||
{
|
||||
static launch_exp_t Host;
|
||||
|
||||
// Sys_LoadLibrary can create fake instance, to check
|
||||
// api version and api size, but first argument will be 0
|
||||
// and always make exception, run simply check for avoid it
|
||||
if(input) std = *input;
|
||||
std = *input;
|
||||
|
||||
Host.api_size = sizeof(launch_exp_t);
|
||||
|
||||
|
|
|
@ -379,14 +379,13 @@ typedef struct vidmode_s
|
|||
|
||||
vidmode_t vid_modes[] =
|
||||
{
|
||||
{ "Mode 0: 320x240", 320, 240, 0 },
|
||||
{ "Mode 1: 640x480", 640, 480, 1 },
|
||||
{ "Mode 2: 800x600", 800, 600, 2 },
|
||||
{ "Mode 3: 1024x768", 1024, 768, 3 },
|
||||
{ "Mode 4: 1280x960", 1280, 960, 4 },
|
||||
{ "Mode 5: 1280x1024", 1280, 1024, 5 },
|
||||
{ "Mode 6: 1600x1200", 1600, 1200, 6 },
|
||||
{ "Mode 7: 2048x1536", 2048, 1536, 7 }
|
||||
{ "Mode 0: 640x480", 640, 480, 1 },
|
||||
{ "Mode 1: 800x600", 800, 600, 2 },
|
||||
{ "Mode 2: 1024x768", 1024, 768, 3 },
|
||||
{ "Mode 3: 1280x960", 1280, 960, 4 },
|
||||
{ "Mode 4: 1280x1024", 1280, 1024, 5 },
|
||||
{ "Mode 5: 1600x1200", 1600, 1200, 6 },
|
||||
{ "Mode 6: 2048x1536", 2048, 1536, 7 }
|
||||
};
|
||||
|
||||
bool VID_GetModeInfo( int *width, int *height, int mode )
|
||||
|
@ -442,11 +441,6 @@ void VID_FreeReflib (void)
|
|||
reflib_active = false;
|
||||
}
|
||||
|
||||
char *FS_Gamedir( void )
|
||||
{
|
||||
return std.GameInfo->gamedir;
|
||||
}
|
||||
|
||||
cvar_t *VID_Cvar_Get(const char *var_name, const char *value, int flags)
|
||||
{
|
||||
return _Cvar_Get(var_name, value, flags, "render variable" );
|
||||
|
@ -457,11 +451,6 @@ void VID_Cmd_AddCommand(const char *cmd_name, xcommand_t function)
|
|||
_Cmd_AddCommand(cmd_name, function, "render command" );
|
||||
}
|
||||
|
||||
char *FS_Title( void )
|
||||
{
|
||||
return std.GameInfo->title;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
VID_InitRender
|
||||
|
@ -470,16 +459,12 @@ VID_InitRender
|
|||
void VID_InitRender( void )
|
||||
{
|
||||
static render_imp_t ri;
|
||||
render_t CreateRender;
|
||||
stdlib_api_t io = Host_GetStdio( false );
|
||||
launch_t CreateRender;
|
||||
|
||||
VID_FreeRender();
|
||||
|
||||
ri.LoadImage = Com->LoadImage;
|
||||
ri.FreeImage = Com->FreeImage;
|
||||
ri.SaveImage = Com->SaveImage;
|
||||
|
||||
ri.Compile = Com->Compile;
|
||||
ri.Stdio = Host_GetStdio( false );
|
||||
ri.api_size = sizeof(render_imp_t);
|
||||
|
||||
ri.Cmd_AddCommand = VID_Cmd_AddCommand;
|
||||
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
||||
|
@ -487,23 +472,22 @@ void VID_InitRender( void )
|
|||
ri.Cmd_Argv = Cmd_Argv;
|
||||
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
|
||||
|
||||
ri.gamedir = FS_Gamedir;
|
||||
ri.title = FS_Title;
|
||||
// studio callbacks
|
||||
ri.StudioEvent = CL_StudioEvent;
|
||||
ri.ShowCollision = Phys->ShowCollision;
|
||||
|
||||
ri.Cvar_Get = VID_Cvar_Get;
|
||||
ri.Cvar_Set = Cvar_Set;
|
||||
ri.Cvar_SetValue = Cvar_SetValue;
|
||||
|
||||
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
||||
ri.Vid_MenuInit = VID_MenuInit;
|
||||
ri.Vid_NewWindow = VID_NewWindow;
|
||||
|
||||
// studio callbacks
|
||||
ri.StudioEvent = CL_StudioEvent;
|
||||
ri.ShowCollision = Phys->ShowCollision;
|
||||
|
||||
Sys_LoadLibrary( &render_dll );
|
||||
|
||||
CreateRender = (void *)render_dll.main;
|
||||
re = CreateRender( &ri );
|
||||
re = CreateRender( &io, &ri );
|
||||
|
||||
if(!re->Init( global_hInstance, MainWndProc ))
|
||||
Sys_Error("VID_InitRender: can't init render.dll\nUpdate your opengl drivers\n");
|
||||
|
@ -584,7 +568,7 @@ void VID_FreeRender (void)
|
|||
{
|
||||
if ( reflib_active )
|
||||
{
|
||||
re->Shutdown ();
|
||||
re->Shutdown();
|
||||
VID_FreeReflib ();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -96,7 +96,6 @@ void VID_MenuInit( void )
|
|||
{
|
||||
static const char *resolutions[] =
|
||||
{
|
||||
"[320 240 ]",
|
||||
"[640 480 ]",
|
||||
"[800 600 ]",
|
||||
"[1024 768 ]",
|
||||
|
|
|
@ -21,8 +21,8 @@ WIN32 CONSOLE
|
|||
#define SUBMIT_ID 1 // "submit" button
|
||||
#define QUIT_ON_ESCPE_ID 2 // escape event
|
||||
#define QUIT_ON_SPACE_ID 3 // space event
|
||||
#define EDIT_ID 100
|
||||
#define INPUT_ID 101
|
||||
#define EDIT_ID 110
|
||||
#define INPUT_ID 109
|
||||
#define IDI_ICON1 101
|
||||
#define SYSCONSOLE "SystemConsole"
|
||||
|
||||
|
@ -51,7 +51,7 @@ static WinConData s_wcd;
|
|||
|
||||
void Con_ShowConsole( bool show )
|
||||
{
|
||||
if( !s_wcd.hWnd || sys.hooked_out )
|
||||
if( !s_wcd.hWnd || Sys.hooked_out )
|
||||
return;
|
||||
if ( show == s_wcd.status )
|
||||
return;
|
||||
|
@ -82,7 +82,7 @@ static long _stdcall Con_WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lP
|
|||
return TRUE;
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
if(sys.error)
|
||||
if(Sys.error)
|
||||
{
|
||||
// send windows message
|
||||
PostQuitMessage( 0 );
|
||||
|
@ -234,24 +234,24 @@ void Con_CreateConsole( void )
|
|||
int CONSTYLE = WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_BORDER | WS_EX_CLIENTEDGE | ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | ES_READONLY;
|
||||
char Title[MAX_QPATH], FontName[MAX_QPATH];
|
||||
|
||||
if(sys.con_silentmode) return;
|
||||
if(Sys.con_silentmode) return;
|
||||
|
||||
if(sys.hooked_out)
|
||||
if(Sys.hooked_out)
|
||||
{
|
||||
// just init log
|
||||
sys.Con_Print = Con_PrintA;
|
||||
Sys.Con_Print = Con_PrintA;
|
||||
Sys_InitLog();
|
||||
return;
|
||||
}
|
||||
sys.Con_Print = Con_PrintW;
|
||||
Sys.Con_Print = Con_PrintW;
|
||||
|
||||
Mem_Set( &wc, 0, sizeof( wc ));
|
||||
wc.style = 0;
|
||||
wc.lpfnWndProc = (WNDPROC)Con_WndProc;
|
||||
wc.cbClsExtra = 0;
|
||||
wc.cbWndExtra = 0;
|
||||
wc.hInstance = base_hInstance;
|
||||
wc.hIcon = LoadIcon( base_hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||
wc.hInstance = Sys.hInstance;
|
||||
wc.hIcon = LoadIcon( Sys.hInstance, MAKEINTRESOURCE(IDI_ICON1));
|
||||
wc.hCursor = LoadCursor (NULL,IDC_ARROW);
|
||||
wc.hbrBackground = (void *)COLOR_3DSHADOW;
|
||||
wc.lpszMenuName = 0;
|
||||
|
@ -259,7 +259,7 @@ void Con_CreateConsole( void )
|
|||
|
||||
if (!RegisterClass (&wc)) Sys_ErrorFatal( ERR_CONSOLE_FAIL );
|
||||
|
||||
if(sys.con_showcredits)
|
||||
if(Sys.con_showcredits)
|
||||
{
|
||||
CONSTYLE &= ~WS_VSCROLL;
|
||||
rect.left = 0;
|
||||
|
@ -269,7 +269,7 @@ void Con_CreateConsole( void )
|
|||
com_strncpy(FontName, "Arial", MAX_QPATH );
|
||||
fontsize = 16;
|
||||
}
|
||||
else if(sys.con_readonly)
|
||||
else if(Sys.con_readonly)
|
||||
{
|
||||
rect.left = 0;
|
||||
rect.right = 536;
|
||||
|
@ -288,7 +288,7 @@ void Con_CreateConsole( void )
|
|||
fontsize = 14;
|
||||
}
|
||||
|
||||
com_strncpy( Title, sys.caption, MAX_QPATH );
|
||||
com_strncpy( Title, Sys.caption, MAX_QPATH );
|
||||
AdjustWindowRect( &rect, DEDSTYLE, FALSE );
|
||||
|
||||
hDC = GetDC( GetDesktopWindow() );
|
||||
|
@ -308,7 +308,7 @@ void Con_CreateConsole( void )
|
|||
s_wcd.hfBufferFont = CreateFont( nHeight, 0, 0, 0, FW_LIGHT, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, FF_MODERN | FIXED_PITCH, FontName );
|
||||
ReleaseDC( s_wcd.hWnd, hDC );
|
||||
|
||||
if(!sys.con_readonly)
|
||||
if(!Sys.con_readonly)
|
||||
{
|
||||
// create the input line
|
||||
s_wcd.hwndInputLine = CreateWindowEx( WS_EX_CLIENTEDGE, "edit", NULL, WS_CHILD | WS_VISIBLE | WS_BORDER | ES_LEFT | ES_AUTOHSCROLL, 0, 366, 450, 25, s_wcd.hWnd, ( HMENU ) INPUT_ID, base_hInstance, NULL );
|
||||
|
@ -323,7 +323,7 @@ void Con_CreateConsole( void )
|
|||
s_wcd.hwndBuffer = CreateWindowEx(WS_EX_DLGMODALFRAME | WS_EX_CLIENTEDGE, "edit", NULL, CONSTYLE, 0, 0, rect.right - rect.left, min(365, rect.bottom), s_wcd.hWnd, ( HMENU )EDIT_ID, base_hInstance, NULL );
|
||||
SendMessage( s_wcd.hwndBuffer, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
|
||||
|
||||
if(!sys.con_readonly)
|
||||
if(!Sys.con_readonly)
|
||||
{
|
||||
s_wcd.SysInputLineWndProc = ( WNDPROC )SetWindowLong( s_wcd.hwndInputLine, GWL_WNDPROC, ( long ) Con_InputLineProc );
|
||||
SendMessage( s_wcd.hwndInputLine, WM_SETFONT, ( WPARAM ) s_wcd.hfBufferFont, 0 );
|
||||
|
@ -332,18 +332,21 @@ void Con_CreateConsole( void )
|
|||
Sys_InitLog();
|
||||
|
||||
// show console if needed
|
||||
if( sys.con_showalways )
|
||||
if( Sys.con_showalways )
|
||||
{
|
||||
// make console visible
|
||||
ShowWindow( s_wcd.hWnd, SW_SHOWDEFAULT);
|
||||
UpdateWindow( s_wcd.hWnd );
|
||||
SetForegroundWindow( s_wcd.hWnd );
|
||||
|
||||
if(sys.con_readonly) SetFocus( s_wcd.hWnd );
|
||||
if(Sys.con_readonly) SetFocus( s_wcd.hWnd );
|
||||
else SetFocus( s_wcd.hwndInputLine );
|
||||
s_wcd.status = true;
|
||||
}
|
||||
else s_wcd.status = false;
|
||||
|
||||
// first text message into console or log
|
||||
MsgDev(D_ERROR, "Sys_LoadLibrary: Loading launch.dll - ok\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -358,7 +361,7 @@ void Con_DestroyConsole( void )
|
|||
// last text message into console or log
|
||||
MsgDev(D_ERROR, "Sys_FreeLibrary: Unloading launch.dll\n");
|
||||
|
||||
if(sys.hooked_out)
|
||||
if(Sys.hooked_out)
|
||||
{
|
||||
Sys_CloseLog();
|
||||
return;
|
||||
|
@ -376,7 +379,7 @@ void Con_DestroyConsole( void )
|
|||
s_wcd.hWnd = 0;
|
||||
}
|
||||
|
||||
UnregisterClass (SYSCONSOLE, sys.hInstance);
|
||||
UnregisterClass (SYSCONSOLE, Sys.hInstance);
|
||||
Sys_CloseLog();
|
||||
}
|
||||
|
||||
|
@ -406,7 +409,7 @@ change focus to console hwnd
|
|||
*/
|
||||
void Con_RegisterHotkeys( void )
|
||||
{
|
||||
if(sys.hooked_out) return;
|
||||
if(Sys.hooked_out) return;
|
||||
|
||||
SetFocus( s_wcd.hWnd );
|
||||
|
||||
|
|
|
@ -2410,46 +2410,6 @@ void FS_UpdateEnvironmentVariables( void )
|
|||
/*
|
||||
=============================================================================
|
||||
|
||||
EXTERNAL FILESYSTEM INTERFACE
|
||||
=============================================================================
|
||||
*/
|
||||
filesystem_api_t FS_GetAPI( void )
|
||||
{
|
||||
static filesystem_api_t fs;
|
||||
|
||||
fs.api_size = sizeof(filesystem_api_t);
|
||||
|
||||
fs.FileBase = FS_FileBase;
|
||||
fs.FileExists = FS_FileExists;
|
||||
fs.FileSize = FS_FileSize;
|
||||
fs.FileExtension = FS_FileExtension;
|
||||
fs.FileWithoutPath = FS_FileWithoutPath;
|
||||
fs.StripExtension = FS_StripExtension;
|
||||
fs.StripFilePath = FS_ExtractFilePath;
|
||||
fs.DefaultExtension = FS_DefaultExtension;
|
||||
fs.ClearSearchPath = FS_ClearSearchPath;
|
||||
|
||||
fs.Search = FS_Search;
|
||||
|
||||
fs.Open = FS_Open;
|
||||
fs.Close = FS_Close;
|
||||
fs.Write = FS_Write;
|
||||
fs.Read = FS_Read;
|
||||
fs.Print = FS_Print;
|
||||
fs.Printf = FS_Printf;
|
||||
fs.Gets = FS_Gets;
|
||||
fs.Seek = FS_Seek;
|
||||
fs.Tell = FS_Tell;
|
||||
|
||||
fs.LoadFile = FS_LoadFile;
|
||||
fs.WriteFile = FS_WriteFile;
|
||||
|
||||
return fs;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
VIRTUAL FILE SYSTEM - WRITE DATA INTO MEMORY
|
||||
|
||||
=============================================================================
|
||||
|
@ -2562,6 +2522,34 @@ fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size )
|
|||
return file->length;
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
VFS_Write2
|
||||
|
||||
deflate buffer and write into virtual file
|
||||
================
|
||||
*/
|
||||
fs_offset_t VFS_Write2( vfile_t *handle, byte *buffer, size_t size )
|
||||
{
|
||||
int i = 0;
|
||||
char out[8192]; // chunk size
|
||||
z_stream strm = { buffer, size, 0, out, sizeof(out), 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
deflateInit( &strm, 9 ); // Z_BEST_COMPRESSION
|
||||
while(deflate( &strm, Z_FINISH) == Z_OK)
|
||||
{
|
||||
VFS_Write( handle, out, sizeof(out) - strm.avail_out);
|
||||
i += sizeof(out) - strm.avail_out;
|
||||
strm.next_out = out;
|
||||
strm.avail_out = sizeof(out);
|
||||
}
|
||||
VFS_Write( handle, out, sizeof(out) - strm.avail_out );
|
||||
i += sizeof(out) - strm.avail_out;
|
||||
deflateEnd( &strm );
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
fs_offset_t VFS_Tell (vfile_t* file)
|
||||
{
|
||||
if (!file) return -1;
|
||||
|
@ -2593,6 +2581,22 @@ int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence )
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool VFS_Unpack( void* compbuf, size_t compsize, void **dst, size_t size )
|
||||
{
|
||||
char *buf = *dst;
|
||||
z_stream strm = {compbuf, compsize, 0, buf, size, 0, NULL, NULL, NULL, NULL, NULL, 0, 0, 0 };
|
||||
|
||||
inflateInit( &strm );
|
||||
if (Z_STREAM_END != inflate( &strm, Z_FINISH )) // decompress it in one go.
|
||||
{
|
||||
if(!com_strlen(strm.msg)) MsgDev(D_NOTE, "VFS_Unpack: failed block decompression\n" );
|
||||
else MsgDev(D_NOTE, "VFS_Unpack: failed block decompression: %s\n", strm.msg );
|
||||
return false;
|
||||
}
|
||||
inflateEnd( &strm );
|
||||
return true;
|
||||
}
|
||||
|
||||
int VFS_Close( vfile_t *file )
|
||||
{
|
||||
if(!file) return -1;
|
||||
|
@ -2608,26 +2612,3 @@ int VFS_Close( vfile_t *file )
|
|||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
VIRTUAL FILESYSTEM INTERFACE
|
||||
=============================================================================
|
||||
*/
|
||||
vfilesystem_api_t VFS_GetAPI( void )
|
||||
{
|
||||
static vfilesystem_api_t vfs;
|
||||
|
||||
vfs.api_size = sizeof(vfilesystem_api_t);
|
||||
|
||||
vfs.Create = VFS_Create;
|
||||
vfs.Open = VFS_Open;
|
||||
vfs.Close = VFS_Close;
|
||||
vfs.Write = VFS_Write;
|
||||
vfs.Read = VFS_Read;
|
||||
vfs.Seek = VFS_Seek;
|
||||
vfs.Tell = VFS_Tell;
|
||||
|
||||
return vfs;
|
||||
}
|
|
@ -0,0 +1,348 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// image.h - tga, pcx image headers
|
||||
//=======================================================================
|
||||
|
||||
#ifndef IMAGE_H
|
||||
#define IMAGE_H
|
||||
|
||||
static byte palette_d1[768] =
|
||||
{
|
||||
0,0,0,31,23,11,23,15,7,75,75,75,255,255,255,27,27,27,19,19,19,11,11,11,7,7,7,47,55,31,35,43,15,23,31,7,15,23,0,79,
|
||||
59,43,71,51,35,63,43,27,255,183,183,247,171,171,243,163,163,235,151,151,231,143,143,223,135,135,219,123,123,211,115,
|
||||
115,203,107,107,199,99,99,191,91,91,187,87,87,179,79,79,175,71,71,167,63,63,163,59,59,155,51,51,151,47,47,143,43,43,
|
||||
139,35,35,131,31,31,127,27,27,119,23,23,115,19,19,107,15,15,103,11,11,95,7,7,91,7,7,83,7,7,79,0,0,71,0,0,67,0,0,255,
|
||||
235,223,255,227,211,255,219,199,255,211,187,255,207,179,255,199,167,255,191,155,255,187,147,255,179,131,247,171,123,
|
||||
239,163,115,231,155,107,223,147,99,215,139,91,207,131,83,203,127,79,191,123,75,179,115,71,171,111,67,163,107,63,155,
|
||||
99,59,143,95,55,135,87,51,127,83,47,119,79,43,107,71,39,95,67,35,83,63,31,75,55,27,63,47,23,51,43,19,43,35,15,239,
|
||||
239,239,231,231,231,223,223,223,219,219,219,211,211,211,203,203,203,199,199,199,191,191,191,183,183,183,179,179,179,
|
||||
171,171,171,167,167,167,159,159,159,151,151,151,147,147,147,139,139,139,131,131,131,127,127,127,119,119,119,111,111,
|
||||
111,107,107,107,99,99,99,91,91,91,87,87,87,79,79,79,71,71,71,67,67,67,59,59,59,55,55,55,47,47,47,39,39,39,35,35,35,
|
||||
119,255,111,111,239,103,103,223,95,95,207,87,91,191,79,83,175,71,75,159,63,67,147,55,63,131,47,55,115,43,47,99,35,39,
|
||||
83,27,31,67,23,23,51,15,19,35,11,11,23,7,191,167,143,183,159,135,175,151,127,167,143,119,159,135,111,155,127,107,147,
|
||||
123,99,139,115,91,131,107,87,123,99,79,119,95,75,111,87,67,103,83,63,95,75,55,87,67,51,83,63,47,159,131,99,143,119,83,
|
||||
131,107,75,119,95,63,103,83,51,91,71,43,79,59,35,67,51,27,123,127,99,111,115,87,103,107,79,91,99,71,83,87,59,71,79,51,
|
||||
63,71,43,55,63,39,255,255,115,235,219,87,215,187,67,195,155,47,175,123,31,155,91,19,135,67,7,115,43,0,255,255,255,255,
|
||||
219,219,255,187,187,255,155,155,255,123,123,255,95,95,255,63,63,255,31,31,255,0,0,239,0,0,227,0,0,215,0,0,203,0,0,191,
|
||||
0,0,179,0,0,167,0,0,155,0,0,139,0,0,127,0,0,115,0,0,103,0,0,91,0,0,79,0,0,67,0,0,231,231,255,199,199,255,171,171,255,
|
||||
143,143,255,115,115,255,83,83,255,55,55,255,27,27,255,0,0,255,0,0,227,0,0,203,0,0,179,0,0,155,0,0,131,0,0,107,0,0,83,
|
||||
255,255,255,255,235,219,255,215,187,255,199,155,255,179,123,255,163,91,255,143,59,255,127,27,243,115,23,235,111,15,
|
||||
223,103,15,215,95,11,203,87,7,195,79,0,183,71,0,175,67,0,255,255,255,255,255,215,255,255,179,255,255,143,255,255,107,
|
||||
255,255,71,255,255,35,255,255,0,167,63,0,159,55,0,147,47,0,135,35,0,79,59,39,67,47,27,55,35,19,47,27,11,0,0,83,0,0,71,
|
||||
0,0,59,0,0,47,0,0,35,0,0,23,0,0,11,0,255,255,255,159,67,255,231,75,255,123,255,255,0,255,207,0,207,159,0,155,111,0,107,
|
||||
167,107,107
|
||||
};
|
||||
|
||||
static byte palette_q1[768] =
|
||||
{
|
||||
0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,
|
||||
171,171,187,187,187,203,203,203,219,219,219,235,235,235,15,11,7,23,15,11,31,23,11,39,27,15,47,35,19,55,43,23,63,
|
||||
47,23,75,55,27,83,59,27,91,67,31,99,75,31,107,83,31,115,87,31,123,95,35,131,103,35,143,111,35,11,11,15,19,19,27,
|
||||
27,27,39,39,39,51,47,47,63,55,55,75,63,63,87,71,71,103,79,79,115,91,91,127,99,99,139,107,107,151,115,115,163,123,
|
||||
123,175,131,131,187,139,139,203,0,0,0,7,7,0,11,11,0,19,19,0,27,27,0,35,35,0,43,43,7,47,47,7,55,55,7,63,63,7,71,71,
|
||||
7,75,75,11,83,83,11,91,91,11,99,99,11,107,107,15,7,0,0,15,0,0,23,0,0,31,0,0,39,0,0,47,0,0,55,0,0,63,0,0,71,0,0,79,
|
||||
0,0,87,0,0,95,0,0,103,0,0,111,0,0,119,0,0,127,0,0,19,19,0,27,27,0,35,35,0,47,43,0,55,47,0,67,55,0,75,59,7,87,67,7,
|
||||
95,71,7,107,75,11,119,83,15,131,87,19,139,91,19,151,95,27,163,99,31,175,103,35,35,19,7,47,23,11,59,31,15,75,35,19,
|
||||
87,43,23,99,47,31,115,55,35,127,59,43,143,67,51,159,79,51,175,99,47,191,119,47,207,143,43,223,171,39,239,203,31,255,
|
||||
243,27,11,7,0,27,19,0,43,35,15,55,43,19,71,51,27,83,55,35,99,63,43,111,71,51,127,83,63,139,95,71,155,107,83,167,123,
|
||||
95,183,135,107,195,147,123,211,163,139,227,179,151,171,139,163,159,127,151,147,115,135,139,103,123,127,91,111,119,
|
||||
83,99,107,75,87,95,63,75,87,55,67,75,47,55,67,39,47,55,31,35,43,23,27,35,19,19,23,11,11,15,7,7,187,115,159,175,107,
|
||||
143,163,95,131,151,87,119,139,79,107,127,75,95,115,67,83,107,59,75,95,51,63,83,43,55,71,35,43,59,31,35,47,23,27,35,
|
||||
19,19,23,11,11,15,7,7,219,195,187,203,179,167,191,163,155,175,151,139,163,135,123,151,123,111,135,111,95,123,99,83,
|
||||
107,87,71,95,75,59,83,63,51,67,51,39,55,43,31,39,31,23,27,19,15,15,11,7,111,131,123,103,123,111,95,115,103,87,107,
|
||||
95,79,99,87,71,91,79,63,83,71,55,75,63,47,67,55,43,59,47,35,51,39,31,43,31,23,35,23,15,27,19,11,19,11,7,11,7,255,
|
||||
243,27,239,223,23,219,203,19,203,183,15,187,167,15,171,151,11,155,131,7,139,115,7,123,99,7,107,83,0,91,71,0,75,55,
|
||||
0,59,43,0,43,31,0,27,15,0,11,7,0,0,0,255,11,11,239,19,19,223,27,27,207,35,35,191,43,43,175,47,47,159,47,47,143,47,
|
||||
47,127,47,47,111,47,47,95,43,43,79,35,35,63,27,27,47,19,19,31,11,11,15,43,0,0,59,0,0,75,7,0,95,7,0,111,15,0,127,23,
|
||||
7,147,31,7,163,39,11,183,51,15,195,75,27,207,99,43,219,127,59,227,151,79,231,171,95,239,191,119,247,211,139,167,123,
|
||||
59,183,155,55,199,195,55,231,227,87,127,191,255,171,231,255,215,255,255,103,0,0,139,0,0,179,0,0,215,0,0,255,0,0,255,
|
||||
243,147,255,247,199,255,255,255,159,91,83
|
||||
};
|
||||
|
||||
static byte palette_q2[768] =
|
||||
{
|
||||
0,0,0,15,15,15,31,31,31,47,47,47,63,63,63,75,75,75,91,91,91,107,107,107,123,123,123,139,139,139,155,155,155,171,171,
|
||||
171,187,187,187,203,203,203,219,219,219,235,235,235,99,75,35,91,67,31,83,63,31,79,59,27,71,55,27,63,47,23,59,43,23,
|
||||
51,39,19,47,35,19,43,31,19,39,27,15,35,23,15,27,19,11,23,15,11,19,15,7,15,11,7,95,95,111,91,91,103,91,83,95,87,79,91,
|
||||
83,75,83,79,71,75,71,63,67,63,59,59,59,55,55,51,47,47,47,43,43,39,39,39,35,35,35,27,27,27,23,23,23,19,19,19,143,119,
|
||||
83,123,99,67,115,91,59,103,79,47,207,151,75,167,123,59,139,103,47,111,83,39,235,159,39,203,139,35,175,119,31,147,99,
|
||||
27,119,79,23,91,59,15,63,39,11,35,23,7,167,59,43,159,47,35,151,43,27,139,39,19,127,31,15,115,23,11,103,23,7,87,19,0,
|
||||
75,15,0,67,15,0,59,15,0,51,11,0,43,11,0,35,11,0,27,7,0,19,7,0,123,95,75,115,87,67,107,83,63,103,79,59,95,71,55,87,67,
|
||||
51,83,63,47,75,55,43,67,51,39,63,47,35,55,39,27,47,35,23,39,27,19,31,23,15,23,15,11,15,11,7,111,59,23,95,55,23,83,47,
|
||||
23,67,43,23,55,35,19,39,27,15,27,19,11,15,11,7,179,91,79,191,123,111,203,155,147,215,187,183,203,215,223,179,199,211,
|
||||
159,183,195,135,167,183,115,151,167,91,135,155,71,119,139,47,103,127,23,83,111,19,75,103,15,67,91,11,63,83,7,55,75,7,
|
||||
47,63,7,39,51,0,31,43,0,23,31,0,15,19,0,7,11,0,0,0,139,87,87,131,79,79,123,71,71,115,67,67,107,59,59,99,51,51,91,47,
|
||||
47,87,43,43,75,35,35,63,31,31,51,27,27,43,19,19,31,15,15,19,11,11,11,7,7,0,0,0,151,159,123,143,151,115,135,139,107,
|
||||
127,131,99,119,123,95,115,115,87,107,107,79,99,99,71,91,91,67,79,79,59,67,67,51,55,55,43,47,47,35,35,35,27,23,23,19,
|
||||
15,15,11,159,75,63,147,67,55,139,59,47,127,55,39,119,47,35,107,43,27,99,35,23,87,31,19,79,27,15,67,23,11,55,19,11,43,
|
||||
15,7,31,11,7,23,7,0,11,0,0,0,0,0,119,123,207,111,115,195,103,107,183,99,99,167,91,91,155,83,87,143,75,79,127,71,71,
|
||||
115,63,63,103,55,55,87,47,47,75,39,39,63,35,31,47,27,23,35,19,15,23,11,7,7,155,171,123,143,159,111,135,151,99,123,
|
||||
139,87,115,131,75,103,119,67,95,111,59,87,103,51,75,91,39,63,79,27,55,67,19,47,59,11,35,47,7,27,35,0,19,23,0,11,15,
|
||||
0,0,255,0,35,231,15,63,211,27,83,187,39,95,167,47,95,143,51,95,123,51,255,255,255,255,255,211,255,255,167,255,255,
|
||||
127,255,255,83,255,255,39,255,235,31,255,215,23,255,191,15,255,171,7,255,147,0,239,127,0,227,107,0,211,87,0,199,71,
|
||||
0,183,59,0,171,43,0,155,31,0,143,23,0,127,15,0,115,7,0,95,0,0,71,0,0,47,0,0,27,0,0,239,0,0,55,55,255,255,0,0,0,0,255,
|
||||
43,43,35,27,27,23,19,19,15,235,151,127,195,115,83,159,87,51,123,63,27,235,211,199,199,171,155,167,139,119,135,107,87,
|
||||
159,91,83
|
||||
};
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.PCX image format (ZSoft Paintbrush)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
char manufacturer;
|
||||
char version;
|
||||
char encoding;
|
||||
char bits_per_pixel;
|
||||
word xmin,ymin,xmax,ymax;
|
||||
word hres,vres;
|
||||
byte palette[48];
|
||||
char reserved;
|
||||
char color_planes;
|
||||
word bytes_per_line;
|
||||
word palette_type;
|
||||
char filler[58];
|
||||
} pcx_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.WAL image format (Wally textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct wal_s
|
||||
{
|
||||
char name[32];
|
||||
uint width, height;
|
||||
uint offsets[4]; // four mip maps stored
|
||||
char animname[32]; // next frame in animation chain
|
||||
int flags;
|
||||
int contents;
|
||||
int value;
|
||||
} wal_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.LMP image format (Quake1 lumps)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct lmp_s
|
||||
{
|
||||
uint width;
|
||||
uint height;
|
||||
} lmp_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.MIP image format (Quake1 textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct mip_s
|
||||
{
|
||||
char name[16];
|
||||
uint width, height;
|
||||
uint offsets[4]; // four mip maps stored
|
||||
} mip_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.FLAT image format (Doom I\II textures)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct flat_s
|
||||
{
|
||||
short width;
|
||||
short height;
|
||||
long desc; // image desc (not used)
|
||||
} flat_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.TGA image format (Truevision Targa)
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct tga_s
|
||||
{
|
||||
byte id_length;
|
||||
byte colormap_type;
|
||||
byte image_type;
|
||||
word colormap_index;
|
||||
word colormap_length;
|
||||
byte colormap_size;
|
||||
word x_origin;
|
||||
word y_origin;
|
||||
word width;
|
||||
word height;
|
||||
byte pixel_size;
|
||||
byte attributes;
|
||||
} tga_t;
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.DDS image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
#define DDSHEADER ((' '<<24)+('S'<<16)+('D'<<8)+'D') // little-endian "DDS "
|
||||
|
||||
//other four-cc types
|
||||
#define TYPE_DXT1 (('1'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT1"
|
||||
#define TYPE_DXT2 (('2'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT2"
|
||||
#define TYPE_DXT3 (('3'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT3"
|
||||
#define TYPE_DXT4 (('4'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT4"
|
||||
#define TYPE_DXT5 (('5'<<24)+('T'<<16)+('X'<<8)+'D') // little-endian "DXT5"
|
||||
|
||||
#define TYPE_ATI1 (('1'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI1"
|
||||
#define TYPE_ATI2 (('2'<<24)+('I'<<16)+('T'<<8)+'A') // little-endian "ATI2"
|
||||
|
||||
|
||||
#define TYPE_RXGB (('B'<<24)+('G'<<16)+('X'<<8)+'R') // little-endian "RXGB" doom3 normalmaps
|
||||
#define TYPE_$ (('\0'<<24)+('\0'<<16)+('\0'<<8)+'$') // little-endian "$"
|
||||
|
||||
#define DDS_CAPS 0x00000001L
|
||||
#define DDS_HEIGHT 0x00000002L
|
||||
#define DDS_WIDTH 0x00000004L
|
||||
|
||||
#define DDS_RGB 0x00000040L
|
||||
#define DDS_PIXELFORMAT 0x00001000L
|
||||
#define DDS_LUMINANCE 0x00020000L
|
||||
|
||||
#define DDS_ALPHAPIXELS 0x00000001L
|
||||
#define DDS_ALPHA 0x00000002L
|
||||
#define DDS_FOURCC 0x00000004L
|
||||
#define DDS_PITCH 0x00000008L
|
||||
#define DDS_COMPLEX 0x00000008L
|
||||
#define DDS_CUBEMAP 0x00000200L
|
||||
#define DDS_CUBEMAP_POSITIVEX 0x00000400L
|
||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000800L
|
||||
#define DDS_CUBEMAP_POSITIVEY 0x00001000L
|
||||
#define DDS_CUBEMAP_NEGATIVEY 0x00002000L
|
||||
#define DDS_CUBEMAP_POSITIVEZ 0x00004000L
|
||||
#define DDS_CUBEMAP_NEGATIVEZ 0x00008000L
|
||||
#define DDS_MIPMAPCOUNT 0x00020000L
|
||||
#define DDS_LINEARSIZE 0x00080000L
|
||||
#define DDS_VOLUME 0x00200000L
|
||||
#define DDS_MIPMAP 0x00400000L
|
||||
#define DDS_DEPTH 0x00800000L
|
||||
|
||||
typedef struct dds_pf_s
|
||||
{
|
||||
uint dwSize;
|
||||
uint dwFlags;
|
||||
uint dwFourCC;
|
||||
uint dwRGBBitCount;
|
||||
uint dwRBitMask;
|
||||
uint dwGBitMask;
|
||||
uint dwBBitMask;
|
||||
uint dwABitMask;
|
||||
} dds_pixf_t;
|
||||
|
||||
// DDCAPS2
|
||||
typedef struct dds_caps_s
|
||||
{
|
||||
uint dwCaps1;
|
||||
uint dwCaps2;
|
||||
uint dwCaps3;
|
||||
uint dwCaps4;
|
||||
} dds_caps_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint dwIdent; // must matched with DDSHEADER
|
||||
uint dwSize;
|
||||
uint dwFlags; // determines what fields are valid
|
||||
uint dwHeight;
|
||||
uint dwWidth;
|
||||
uint dwLinearSize; // Formless late-allocated optimized surface size
|
||||
uint dwDepth; // depth if a volume texture
|
||||
uint dwMipMapCount; // number of mip-map levels requested
|
||||
uint dwAlphaBitDepth; // depth of alpha buffer requested
|
||||
uint dwReserved1[10]; // reserved for future expansions
|
||||
dds_pixf_t dsPixelFormat;
|
||||
dds_caps_t dsCaps;
|
||||
uint dwTextureStage;
|
||||
} dds_t;
|
||||
|
||||
/*
|
||||
========================================================================
|
||||
|
||||
.JPG image format
|
||||
|
||||
========================================================================
|
||||
*/
|
||||
typedef struct huffman_table_s
|
||||
{
|
||||
// Huffman coding tables
|
||||
byte bits[16];
|
||||
byte hval[256];
|
||||
byte size[256];
|
||||
word code[256];
|
||||
|
||||
} huffman_table_t;
|
||||
|
||||
typedef struct jpg_s
|
||||
{
|
||||
// Jpeg file parameter
|
||||
file_t *file; // file
|
||||
byte *buffer; // jpg buffer
|
||||
|
||||
int width; // width image
|
||||
int height; // height image
|
||||
byte *data; // image
|
||||
int data_precision; // bit per component
|
||||
int num_components; // number component
|
||||
int restart_interval; // restart interval
|
||||
bool progressive_mode; // progressive format
|
||||
|
||||
struct
|
||||
{
|
||||
int id; // identifier
|
||||
int h; // horizontal sampling factor
|
||||
int v; // vertical sampling factor
|
||||
int t; // Quantization table selector
|
||||
int td; // DC table selector
|
||||
int ta; // AC table selector
|
||||
} component_info[3];
|
||||
|
||||
huffman_table_t hac[4]; // AC table
|
||||
huffman_table_t hdc[4]; // DC table
|
||||
|
||||
int qtable[4][64]; // Quantization table
|
||||
|
||||
struct
|
||||
{
|
||||
int ss,se; // progressive jpeg spectral selection
|
||||
int ah,al; // progressive jpeg successive approx
|
||||
} scan;
|
||||
|
||||
int dc[3];
|
||||
int curbit;
|
||||
byte curbyte;
|
||||
|
||||
} jpg_t;
|
||||
|
||||
static jpg_t jpg_file;
|
||||
|
||||
// image lib utilites
|
||||
extern uint *d_currentpal;
|
||||
void Image_GetQ1Palette( void );
|
||||
void Image_GetQ2Palette( void );
|
||||
void Image_GetPalettePCX( byte *pal );
|
||||
void Image_Copy8bitRGBA(const byte *in, byte *out, int pixels);
|
||||
void Image_RoundDimensions(int *scaled_width, int *scaled_height);
|
||||
byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outheight, int in_type);
|
||||
|
||||
#endif//IMAGE_H
|
|
@ -3,11 +3,12 @@
|
|||
// image.c - loading textures
|
||||
//=======================================================================
|
||||
|
||||
#include "platform.h"
|
||||
#include "utils.h"
|
||||
#include "archive.h"
|
||||
#include "launch.h"
|
||||
#include "basemath.h" // nearest_pow
|
||||
#include "ref_rgbdata.h"
|
||||
#include "image.h"
|
||||
|
||||
//global image variables
|
||||
// global image variables
|
||||
int image_width, image_height;
|
||||
byte image_num_layers = 1; // num layers in
|
||||
byte image_num_mips = 4; // build mipmaps
|
||||
|
@ -17,7 +18,6 @@ byte image_bits_count; // bits per RGBA
|
|||
size_t image_size; // image rgba size
|
||||
uint image_ptr;
|
||||
|
||||
byte *imagepool; // general image pool
|
||||
byte *image_palette; // palette pointer
|
||||
byte *image_rgba; // image pointer (see image_type for details)
|
||||
|
||||
|
@ -28,136 +28,243 @@ byte *image_cubemap; // cubemap pack
|
|||
uint cubemap_image_type; // shared image type
|
||||
char *suf[6] = {"ft", "bk", "rt", "lf", "up", "dn"};
|
||||
|
||||
bool ImageValidSize( char *name )
|
||||
uint d_8toD1table[256];
|
||||
uint d_8toQ1table[256];
|
||||
uint d_8toQ2table[256];
|
||||
uint d_8to24table[256];
|
||||
uint *d_currentpal;
|
||||
bool d1palette_init = false;
|
||||
bool q1palette_init = false;
|
||||
bool q2palette_init = false;
|
||||
|
||||
//=======================================================================
|
||||
// IMGLIB COMMON TOOLS
|
||||
//=======================================================================
|
||||
|
||||
bool Image_ValidSize( char *name )
|
||||
{
|
||||
if(image_width > 4096 || image_height > 4096 || image_width <= 0 || image_height <= 0)
|
||||
{
|
||||
MsgWarn( "ImageValidSize: (%s) image size out of range [%dx%d]\n", name, image_width, image_height );
|
||||
MsgWarn( "Image_ValidSize: (%s) image size out of range [%dx%d]\n", name, image_width, image_height );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
LoadBMP
|
||||
==============
|
||||
*/
|
||||
bool LoadBMP( char *name, char *buffer, int filesize )
|
||||
void Image_GetPalette( byte *pal, uint *d_table )
|
||||
{
|
||||
int columns, rows, numPixels;
|
||||
byte *buf_p = buffer;
|
||||
int row, column;
|
||||
byte *pixbuf;
|
||||
bmp_t bmpHeader;
|
||||
byte *bmpRGBA;
|
||||
//move pointer
|
||||
Mem_Copy( bmpHeader.id, buf_p, 2 ); buf_p += 2;
|
||||
bmpHeader.fileSize = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.reserved0 = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.bitmapDataOffset = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.bitmapHeaderSize = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.width = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.height = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.planes = BuffLittleShort( buf_p ); buf_p += 2;
|
||||
bmpHeader.bitsPerPixel = BuffLittleShort( buf_p ); buf_p += 2;
|
||||
bmpHeader.compression = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.bitmapDataSize = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.hRes = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.vRes = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.colors = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
bmpHeader.importantColors = BuffLittleLong( buf_p ); buf_p += 4;
|
||||
int i;
|
||||
byte rgba[4];
|
||||
|
||||
Mem_Copy( bmpHeader.palette, buf_p, sizeof( bmpHeader.palette ));
|
||||
if ( bmpHeader.bitsPerPixel == 8 ) buf_p += 1024;
|
||||
// setup palette
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
rgba[0] = 0xFF;
|
||||
rgba[3] = pal[i*3+0];
|
||||
rgba[2] = pal[i*3+1];
|
||||
rgba[1] = pal[i*3+2];
|
||||
d_table[i] = BuffBigLong( rgba );
|
||||
}
|
||||
}
|
||||
|
||||
if ( bmpHeader.id[0] != 'B' && bmpHeader.id[1] != 'M' ) return false; // it's not a bmp file, just skip it
|
||||
if ( bmpHeader.fileSize != filesize )
|
||||
void Image_GetD1Palette( void )
|
||||
{
|
||||
if(!d1palette_init)
|
||||
{
|
||||
MsgWarn( "LoadBMP: (%s) declared filesize does not match real filesize (%d vs. %d)\n", name, bmpHeader.fileSize, filesize );
|
||||
return false;
|
||||
Image_GetPalette( palette_d1, d_8toD1table );
|
||||
d_8toD1table[255] = 247; // 247 is transparent
|
||||
d1palette_init = true;
|
||||
}
|
||||
if ( bmpHeader.compression != 0 )
|
||||
d_currentpal = d_8toD1table;
|
||||
}
|
||||
|
||||
void Image_GetQ1Palette( void )
|
||||
{
|
||||
if(!q1palette_init)
|
||||
{
|
||||
MsgWarn( "LoadBMP: (%s) compressed BMP files is not supported\n", name );
|
||||
return false;
|
||||
Image_GetPalette( palette_q1, d_8toQ1table );
|
||||
d_8toQ1table[255] = 0; // 255 is transparent
|
||||
q1palette_init = true;
|
||||
}
|
||||
if ( bmpHeader.bitsPerPixel < 8 )
|
||||
d_currentpal = d_8toQ1table;
|
||||
}
|
||||
|
||||
void Image_GetQ2Palette( void )
|
||||
{
|
||||
if(!q2palette_init)
|
||||
{
|
||||
MsgWarn( "LoadBMP: (%s) unsupported monochrome format\n", name );
|
||||
return false;
|
||||
Image_GetPalette( palette_q2, d_8toQ2table );
|
||||
d_8toQ2table[255] &= LittleLong(0xffffff);
|
||||
q2palette_init = true;
|
||||
}
|
||||
d_currentpal = d_8toQ2table;
|
||||
}
|
||||
|
||||
void Image_GetPalettePCX( byte *pal )
|
||||
{
|
||||
if(pal)
|
||||
{
|
||||
Image_GetPalette( pal, d_8to24table );
|
||||
d_8to24table[255] &= LittleLong(0xffffff);
|
||||
d_currentpal = d_8to24table;
|
||||
}
|
||||
else Image_GetQ2Palette();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
Image_Copy8bitRGBA
|
||||
|
||||
NOTE: must call Image_GetQ2Palette or Image_GetQ1Palette
|
||||
before used
|
||||
============
|
||||
*/
|
||||
void Image_Copy8bitRGBA(const byte *in, byte *out, int pixels)
|
||||
{
|
||||
int *iout = (int *)out;
|
||||
|
||||
if(!d_currentpal)
|
||||
{
|
||||
MsgDev(D_ERROR,"Image_Copy8bitRGBA: no palette set\n");
|
||||
return;
|
||||
}
|
||||
|
||||
columns = bmpHeader.width;
|
||||
rows = bmpHeader.height;
|
||||
if ( rows < 0 ) rows = -rows;
|
||||
numPixels = columns * rows;
|
||||
|
||||
image_width = columns;
|
||||
image_height = rows;
|
||||
image_num_layers = 1;
|
||||
image_type = PF_RGBA_32;
|
||||
image_size = numPixels * 4;
|
||||
|
||||
if(bmpHeader.bitsPerPixel == 32) image_flags |= IMAGE_HAS_ALPHA;
|
||||
if(!ImageValidSize( name )) return false;
|
||||
image_rgba = bmpRGBA = Mem_Alloc( imagepool, image_size );
|
||||
|
||||
for ( row = rows-1; row >= 0; row-- )
|
||||
while (pixels >= 8)
|
||||
{
|
||||
pixbuf = bmpRGBA + row * columns * 4;
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
iout[2] = d_currentpal[in[2]];
|
||||
iout[3] = d_currentpal[in[3]];
|
||||
iout[4] = d_currentpal[in[4]];
|
||||
iout[5] = d_currentpal[in[5]];
|
||||
iout[6] = d_currentpal[in[6]];
|
||||
iout[7] = d_currentpal[in[7]];
|
||||
in += 8;
|
||||
iout += 8;
|
||||
pixels -= 8;
|
||||
}
|
||||
if (pixels & 4)
|
||||
{
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
iout[2] = d_currentpal[in[2]];
|
||||
iout[3] = d_currentpal[in[3]];
|
||||
in += 4;
|
||||
iout += 4;
|
||||
}
|
||||
if (pixels & 2)
|
||||
{
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
iout[1] = d_currentpal[in[1]];
|
||||
in += 2;
|
||||
iout += 2;
|
||||
}
|
||||
if (pixels & 1)
|
||||
iout[0] = d_currentpal[in[0]];
|
||||
}
|
||||
|
||||
for ( column = 0; column < columns; column++ )
|
||||
|
||||
void Image_RoundDimensions(int *scaled_width, int *scaled_height)
|
||||
{
|
||||
int width = *scaled_width;
|
||||
int height = *scaled_height;
|
||||
|
||||
width = nearest_pow( width );
|
||||
height = nearest_pow( height);
|
||||
|
||||
*scaled_width = bound(1, width, 4096 );
|
||||
*scaled_height = bound(1, height, 4096 );
|
||||
}
|
||||
|
||||
byte *Image_Resample(uint *in, int inwidth, int inheight, int outwidth, int outheight, int in_type )
|
||||
{
|
||||
int i, j;
|
||||
uint frac, fracstep;
|
||||
uint *inrow1, *inrow2;
|
||||
byte *pix1, *pix2, *pix3, *pix4;
|
||||
uint *out, *buf, p1[4096], p2[4096];
|
||||
|
||||
// check for buffers
|
||||
if(!in) return NULL;
|
||||
|
||||
// nothing to resample ?
|
||||
if (inwidth == outwidth && inheight == outheight)
|
||||
return (byte *)in;
|
||||
|
||||
// can't resample compressed formats
|
||||
if(in_type != PF_RGBA_32) return NULL;
|
||||
|
||||
// malloc new buffer
|
||||
out = buf = (uint *)Mem_Alloc( Sys.imagepool, outwidth * outheight * 4 );
|
||||
|
||||
fracstep = inwidth * 0x10000 / outwidth;
|
||||
frac = fracstep>>2;
|
||||
|
||||
for( i = 0; i < outwidth; i++)
|
||||
{
|
||||
p1[i] = 4 * (frac>>16);
|
||||
frac += fracstep;
|
||||
}
|
||||
frac = 3 * (fracstep>>2);
|
||||
|
||||
for( i = 0; i < outwidth; i++)
|
||||
{
|
||||
p2[i] = 4 * (frac>>16);
|
||||
frac += fracstep;
|
||||
}
|
||||
|
||||
for (i = 0; i < outheight; i++,buf += outwidth)
|
||||
{
|
||||
inrow1 = in + inwidth * (int)((i + 0.25) * inheight / outheight);
|
||||
inrow2 = in + inwidth * (int)((i + 0.75) * inheight / outheight);
|
||||
frac = fracstep>>1;
|
||||
|
||||
for (j = 0; j < outwidth; j++)
|
||||
{
|
||||
byte red, green, blue, alpha;
|
||||
int palIndex, x;
|
||||
word shortPixel;
|
||||
|
||||
switch( bmpHeader.bitsPerPixel )
|
||||
{
|
||||
case 8:
|
||||
x = column;
|
||||
palIndex = *buf_p++;
|
||||
*pixbuf++ = bmpHeader.palette[palIndex][2];
|
||||
*pixbuf++ = bmpHeader.palette[palIndex][1];
|
||||
*pixbuf++ = bmpHeader.palette[palIndex][0];
|
||||
*pixbuf++ = 0xff;
|
||||
break;
|
||||
case 16:
|
||||
shortPixel = *(word*)pixbuf;
|
||||
pixbuf += 2;
|
||||
*pixbuf++ = ( shortPixel & ( 31 << 10 ) ) >> 7;
|
||||
*pixbuf++ = ( shortPixel & ( 31 << 5 ) ) >> 2;
|
||||
*pixbuf++ = ( shortPixel & ( 31 ) ) << 3;
|
||||
*pixbuf++ = 0xff;
|
||||
break;
|
||||
|
||||
case 24:
|
||||
blue = *buf_p++;
|
||||
green = *buf_p++;
|
||||
red = *buf_p++;
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
*pixbuf++ = 255;
|
||||
break;
|
||||
case 32:
|
||||
blue = *buf_p++;
|
||||
green = *buf_p++;
|
||||
red = *buf_p++;
|
||||
alpha = *buf_p++;
|
||||
*pixbuf++ = red;
|
||||
*pixbuf++ = green;
|
||||
*pixbuf++ = blue;
|
||||
*pixbuf++ = alpha;
|
||||
break;
|
||||
default:
|
||||
MsgWarn("LoadBMP: (%s) have illegal pixel size '%d'\n", name, bmpHeader.bitsPerPixel );
|
||||
return false;
|
||||
}
|
||||
pix1 = (byte *)inrow1 + p1[j];
|
||||
pix2 = (byte *)inrow1 + p2[j];
|
||||
pix3 = (byte *)inrow2 + p1[j];
|
||||
pix4 = (byte *)inrow2 + p2[j];
|
||||
((byte *)(buf+j))[0] = (pix1[0] + pix2[0] + pix3[0] + pix4[0])>>2;
|
||||
((byte *)(buf+j))[1] = (pix1[1] + pix2[1] + pix3[1] + pix4[1])>>2;
|
||||
((byte *)(buf+j))[2] = (pix1[2] + pix2[2] + pix3[2] + pix4[2])>>2;
|
||||
((byte *)(buf+j))[3] = (pix1[3] + pix2[3] + pix3[3] + pix4[3])>>2;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return (byte *)out;
|
||||
}
|
||||
|
||||
bool Image_Processing( const char *name, rgbdata_t **pix )
|
||||
{
|
||||
int w, h;
|
||||
rgbdata_t *image = *pix;
|
||||
byte *out;
|
||||
char width[4], height[4];
|
||||
|
||||
//check for buffers
|
||||
if(!image || !image->buffer) return false;
|
||||
|
||||
w = image->width;
|
||||
h = image->height;
|
||||
|
||||
if(FS_GetParmFromCmdLine("-w", width ) && FS_GetParmFromCmdLine("-h", height ))
|
||||
{
|
||||
// custom size
|
||||
w = bound(4, atoi(width), 512 );
|
||||
h = bound(4, atoi(height), 512);
|
||||
}
|
||||
else Image_RoundDimensions( &w, &h ); // auto detect new size
|
||||
|
||||
out = Image_Resample((uint *)image->buffer, image->width, image->height, w, h, image->type );
|
||||
if(out != image->buffer)
|
||||
{
|
||||
MsgDev(D_INFO,"Resampling %s from[%d x %d] to[%d x %d]\n",name, image->width, image->height, w, h );
|
||||
Mem_Move( Sys.imagepool, &image->buffer, out, w * h * 4 );// update image->buffer
|
||||
image->width = w,image->height = h;
|
||||
*pix = image;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -185,7 +292,7 @@ bool LoadWAL( char *name, char *buffer, int filesize )
|
|||
ofs = LittleLong(wal.offsets[0]);
|
||||
contents = LittleLong(wal.contents);
|
||||
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
|
||||
pixels = image_width * image_height;
|
||||
mipsize = (int)sizeof(wal) + ofs + pixels;
|
||||
|
@ -198,7 +305,7 @@ bool LoadWAL( char *name, char *buffer, int filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
image_rgba = (byte *)Mem_Alloc( imagepool, image_size );
|
||||
image_rgba = (byte *)Mem_Alloc( Sys.imagepool, image_size );
|
||||
image_num_layers = 1;
|
||||
image_type = PF_RGBA_32;
|
||||
|
||||
|
@ -232,7 +339,7 @@ bool LoadLMP( char *name, char *buffer, int filesize )
|
|||
image_width = LittleLong(lmp.width);
|
||||
image_height = LittleLong(lmp.height);
|
||||
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
image_size = image_width * image_height * 4;
|
||||
pixels = image_width * image_height;
|
||||
|
||||
|
@ -242,7 +349,7 @@ bool LoadLMP( char *name, char *buffer, int filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
image_rgba = (byte *)Mem_Alloc(imagepool, image_size );
|
||||
image_rgba = (byte *)Mem_Alloc(Sys.imagepool, image_size );
|
||||
image_num_layers = 1;
|
||||
image_type = PF_RGBA_32;
|
||||
|
||||
|
@ -282,7 +389,7 @@ bool LoadMIP( char *name, char *buffer, int filesize )
|
|||
image_height = LittleLong(mip.height);
|
||||
ofs = LittleLong(mip.offsets[0]);
|
||||
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
image_size = image_width * image_height * 4;
|
||||
pixels = image_width * image_height;
|
||||
|
||||
|
@ -292,7 +399,7 @@ bool LoadMIP( char *name, char *buffer, int filesize )
|
|||
return false;
|
||||
}
|
||||
|
||||
image_rgba = (byte *)Mem_Alloc(imagepool, image_size );
|
||||
image_rgba = (byte *)Mem_Alloc(Sys.imagepool, image_size );
|
||||
image_num_layers = 1;
|
||||
image_type = PF_RGBA_32;
|
||||
|
||||
|
@ -343,7 +450,7 @@ bool LoadPCX( char *name, char *buffer, int filesize )
|
|||
MsgWarn("LoadPCX: (%s) have illegal pixel size '%d'\n", name, pcx.bits_per_pixel );
|
||||
return false;
|
||||
}
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
palette = buffer + filesize - 768;
|
||||
|
||||
image_num_layers = 1;
|
||||
|
@ -351,14 +458,14 @@ bool LoadPCX( char *name, char *buffer, int filesize )
|
|||
|
||||
if(palette)
|
||||
{
|
||||
image_palette = Mem_Alloc( imagepool, 768 );
|
||||
image_palette = Mem_Alloc( Sys.imagepool, 768 );
|
||||
Mem_Copy( image_palette, palette, 768 );
|
||||
}
|
||||
|
||||
s = image_width * image_height;
|
||||
image_size = image_width * image_height * 4;
|
||||
pbuf = (byte *)Mem_Alloc( imagepool, s );
|
||||
image_rgba = (byte *)Mem_Alloc( imagepool, image_size );
|
||||
pbuf = (byte *)Mem_Alloc( Sys.imagepool, s );
|
||||
image_rgba = (byte *)Mem_Alloc( Sys.imagepool, image_size );
|
||||
trans = (uint *)image_rgba;
|
||||
enddata = palette;
|
||||
|
||||
|
@ -400,7 +507,7 @@ bool LoadPCX( char *name, char *buffer, int filesize )
|
|||
else trans[i] = d_currentpal[p];
|
||||
}
|
||||
|
||||
Free( pbuf ); // free compressed image
|
||||
Mem_Free( pbuf ); // free compressed image
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -437,7 +544,7 @@ bool LoadTGA( char *name, char *buffer, int filesize )
|
|||
targa_header.width = image_width = BuffLittleShort( fin ); fin += 2;
|
||||
targa_header.height = image_height = BuffLittleShort( fin );fin += 2;
|
||||
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
|
||||
image_num_layers = 1;
|
||||
image_type = PF_RGBA_32; //always exctracted to 32-bit buffer
|
||||
|
@ -464,7 +571,7 @@ bool LoadTGA( char *name, char *buffer, int filesize )
|
|||
MsgWarn("LoadTGA: (%s) have unspported indexed colormap\n", name );
|
||||
return false;
|
||||
}
|
||||
image_palette = Mem_Alloc(imagepool, 256*4 );
|
||||
image_palette = Mem_Alloc(Sys.imagepool, 256*4 );
|
||||
|
||||
if (targa_header.colormap_size == 24)
|
||||
{
|
||||
|
@ -543,7 +650,7 @@ bool LoadTGA( char *name, char *buffer, int filesize )
|
|||
|
||||
image_flags |= alphabits ? IMAGE_HAS_ALPHA : 0;
|
||||
image_size = image_width * image_height * 4;
|
||||
image_rgba = Mem_Alloc( imagepool, image_size );
|
||||
image_rgba = Mem_Alloc( Sys.imagepool, image_size );
|
||||
|
||||
// If bit 5 of attributes isn't set, the image has been stored from bottom to top
|
||||
if ((targa_header.attributes & 0x20) == 0)
|
||||
|
@ -861,7 +968,7 @@ void dds_get_pixelformat( dds_t *hdr )
|
|||
if(image_type == PF_ARGB_32 || image_type == PF_LUMINANCE || image_type == PF_LUMINANCE_16 || image_type == PF_LUMINANCE_ALPHA)
|
||||
{
|
||||
//store RGBA mask into one block, and get palette pointer
|
||||
byte *tmp = image_palette = Mem_Alloc( imagepool, sizeof(uint) * 4 );
|
||||
byte *tmp = image_palette = Mem_Alloc( Sys.imagepool, sizeof(uint) * 4 );
|
||||
Mem_Copy( tmp, &hdr->dsPixelFormat.dwRBitMask, sizeof(uint)); tmp += 4;
|
||||
Mem_Copy( tmp, &hdr->dsPixelFormat.dwGBitMask, sizeof(uint)); tmp += 4;
|
||||
Mem_Copy( tmp, &hdr->dsPixelFormat.dwBBitMask, sizeof(uint)); tmp += 4;
|
||||
|
@ -993,7 +1100,7 @@ bool LoadDDS( char *name, char *buffer, int filesize )
|
|||
image_height = header.dwHeight;
|
||||
image_bits_count = header.dsPixelFormat.dwRGBBitCount;
|
||||
if(header.dwFlags & DDS_DEPTH) image_num_layers = header.dwDepth;
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
|
||||
dds_get_pixelformat( &header );// and image type too :)
|
||||
dds_addjust_volume_texture( &header );
|
||||
|
@ -1008,7 +1115,7 @@ bool LoadDDS( char *name, char *buffer, int filesize )
|
|||
if(image_size == 0) return false; // just in case
|
||||
|
||||
// dds files will be uncompressed on a render. requires minimal of info for set this
|
||||
image_rgba = Mem_Alloc( imagepool, image_size );
|
||||
image_rgba = Mem_Alloc( Sys.imagepool, image_size );
|
||||
Mem_Copy( image_rgba, fin, image_size );
|
||||
|
||||
return true;
|
||||
|
@ -1489,10 +1596,10 @@ bool LoadJPG(char *name, char *buffer, int filesize )
|
|||
image_width = jpg_file.width;
|
||||
image_height = jpg_file.height;
|
||||
image_type = PF_RGBA_32;
|
||||
if(!ImageValidSize( name )) return false;
|
||||
if(!Image_ValidSize( name )) return false;
|
||||
|
||||
image_size = jpg_file.width * jpg_file.height * 4;
|
||||
jpg_file.data = Mem_Alloc( imagepool, image_size );
|
||||
jpg_file.data = Mem_Alloc( Sys.imagepool, image_size );
|
||||
|
||||
jpeg_decompress();
|
||||
if(jpg_file.num_components == 1) jpeg_gray2rgba();
|
||||
|
@ -1516,7 +1623,6 @@ loadformat_t load_formats[] =
|
|||
{"textures/%s%s.%s", "dds", LoadDDS},
|
||||
{"textures/%s%s.%s", "tga", LoadTGA},
|
||||
{"textures/%s%s.%s", "jpg", LoadJPG},
|
||||
{"textures/%s%s.%s", "bmp", LoadBMP},
|
||||
{"textures/%s%s.%s", "pcx", LoadPCX},
|
||||
{"textures/%s%s.%s", "wal", LoadWAL},
|
||||
{"textures/%s%s.%s", "lmp", LoadLMP},
|
||||
|
@ -1524,7 +1630,6 @@ loadformat_t load_formats[] =
|
|||
{"%s%s.%s", "dds", LoadDDS},
|
||||
{"%s%s.%s", "tga", LoadTGA},
|
||||
{"%s%s.%s", "jpg", LoadJPG},
|
||||
{"%s%s.%s", "bmp", LoadBMP},
|
||||
{"%s%s.%s", "pcx", LoadPCX},
|
||||
{"%s%s.%s", "wal", LoadWAL},
|
||||
{"%s%s.%s", "lmp", LoadLMP},
|
||||
|
@ -1534,7 +1639,7 @@ loadformat_t load_formats[] =
|
|||
|
||||
rgbdata_t *ImagePack( void )
|
||||
{
|
||||
rgbdata_t *pack = Mem_Alloc( imagepool, sizeof(rgbdata_t));
|
||||
rgbdata_t *pack = Mem_Alloc( Sys.imagepool, sizeof(rgbdata_t));
|
||||
|
||||
if(image_cubemap && cubemap_num_sides != 6)
|
||||
{
|
||||
|
@ -1594,13 +1699,13 @@ bool FS_AddImageToPack( const char *name )
|
|||
if(resampled != image_rgba)
|
||||
{
|
||||
MsgDev(D_NOTE, "FS_AddImageToPack: resample %s from [%dx%d] to [%dx%d]\n", name, image_width, image_height, cubemap_width, cubemap_height );
|
||||
Mem_Move( imagepool, &image_rgba, resampled, image_size );// update buffer
|
||||
Mem_Move( Sys.imagepool, &image_rgba, resampled, image_size );// update buffer
|
||||
}
|
||||
|
||||
image_cubemap = Mem_Realloc( imagepool, image_cubemap, image_ptr + image_size );
|
||||
image_cubemap = Mem_Realloc( Sys.imagepool, image_cubemap, image_ptr + image_size );
|
||||
Mem_Copy(image_cubemap + image_ptr, image_rgba, image_size );
|
||||
|
||||
Free( image_rgba ); // memmove aren't help us
|
||||
Mem_Free( image_rgba ); // memmove aren't help us
|
||||
image_ptr += image_size; // move to next
|
||||
cubemap_num_sides++; // sides counter
|
||||
|
||||
|
@ -1678,7 +1783,7 @@ rgbdata_t *FS_LoadImage(const char *filename, char *buffer, int buffsize )
|
|||
MsgDev(D_ERROR, "FS_LoadImage: couldn't load (%s%s.%s), create balck image\n",loadname,suf[i],ext );
|
||||
|
||||
// Mem_Alloc already filled memblock with 0x00, no need to do it again
|
||||
image_cubemap = Mem_Realloc( imagepool, image_cubemap, image_ptr + image_size );
|
||||
image_cubemap = Mem_Realloc( Sys.imagepool, image_cubemap, image_ptr + image_size );
|
||||
image_ptr += image_size; // move to next
|
||||
cubemap_num_sides++; // merge counter
|
||||
}
|
||||
|
@ -1718,12 +1823,12 @@ void FS_FreeImage( rgbdata_t *pack )
|
|||
{
|
||||
if( pack )
|
||||
{
|
||||
if( pack->buffer ) Free( pack->buffer );
|
||||
if( pack->palette ) Free( pack->palette );
|
||||
Free( pack );
|
||||
if( pack->buffer ) Mem_Free( pack->buffer );
|
||||
if( pack->palette ) Mem_Free( pack->palette );
|
||||
Mem_Free( pack );
|
||||
}
|
||||
|
||||
//reset global variables
|
||||
// reset global variables
|
||||
image_width = image_height = 0;
|
||||
cubemap_width = cubemap_height = 0;
|
||||
image_bits_count = image_flags = 0;
|
||||
|
@ -1753,7 +1858,7 @@ bool SaveTGA( const char *filename, byte *data, int width, int height, bool alph
|
|||
if(alpha) outsize = width * height * 4 + 18 + strlen(comment);
|
||||
else outsize = width * height * 3 + 18 + strlen(comment);
|
||||
|
||||
buffer = (byte *)Z_Malloc( outsize );
|
||||
buffer = (byte *)Malloc( outsize );
|
||||
memset (buffer, 0, 18);
|
||||
|
||||
// prepare header
|
||||
|
@ -1811,7 +1916,7 @@ bool SaveTGA( const char *filename, byte *data, int width, int height, bool alph
|
|||
MsgDev(D_NOTE, "Writing %s[%d]\n", filename, alpha ? 32 : 24 );
|
||||
FS_WriteFile (filename, buffer, outsize );
|
||||
|
||||
Free( buffer );
|
||||
Mem_Free( buffer );
|
||||
return true;
|
||||
}
|
||||
|
|
@ -5,328 +5,6 @@
|
|||
|
||||
#include "launch.h"
|
||||
|
||||
const char *show_credits = "\n\n\n\n\tCopyright XashXT Group 2007 ©\n\t All Rights Reserved\n\n\t Visit www.xash.ru\n";
|
||||
common_exp_t *Com; // callback to utilities
|
||||
launch_exp_t *Host; // callback to mainframe
|
||||
|
||||
stdlib_api_t *Get_StdAPI( void )
|
||||
{
|
||||
static stdlib_api_t std;
|
||||
|
||||
// base events
|
||||
std.printf = Sys_Msg;
|
||||
std.dprintf = Sys_MsgDev;
|
||||
std.wprintf = Sys_MsgWarn;
|
||||
std.error = Sys_Error;
|
||||
std.exit = Sys_Exit;
|
||||
std.print = Sys_Print;
|
||||
std.input = Sys_Input;
|
||||
std.sleep = Sys_Sleep;
|
||||
std.clipboard = Sys_GetClipboardData;
|
||||
|
||||
// multi-thread system
|
||||
std.create_thread = Sys_RunThreadsOnIndividual;
|
||||
std.thread_lock = Sys_ThreadLock;
|
||||
std.thread_unlock = Sys_ThreadUnlock;
|
||||
std.get_numthreads = Sys_GetNumThreads;
|
||||
|
||||
// crclib.c funcs
|
||||
std.crc_init = CRC_Init;
|
||||
std.crc_block = CRC_Block;
|
||||
std.crc_process = CRC_ProcessByte;
|
||||
std.crc_sequence = CRC_BlockSequence;
|
||||
|
||||
// memlib.c
|
||||
std.memcpy = _mem_copy;
|
||||
std.memset = _mem_set;
|
||||
std.realloc = _mem_realloc;
|
||||
std.move = _mem_move;
|
||||
std.malloc = _mem_alloc;
|
||||
std.free = _mem_free;
|
||||
std.mallocpool = _mem_allocpool;
|
||||
std.freepool = _mem_freepool;
|
||||
std.clearpool = _mem_emptypool;
|
||||
std.memcheck = _mem_check;
|
||||
|
||||
std.InitRootDir = FS_InitRootDir; // init custom rootdir
|
||||
std.LoadGameInfo = FS_LoadGameInfo; // gate game info from script file
|
||||
std.AddGameHierarchy = FS_AddGameHierarchy; // add base directory in search list
|
||||
|
||||
std.Fs = FS_GetAPI();
|
||||
std.VFs = VFS_GetAPI();
|
||||
|
||||
// timelib.c funcs
|
||||
std.time_stamp = com_timestamp;
|
||||
std.gettime = Sys_DoubleTime;
|
||||
std.GameInfo = &GI;
|
||||
|
||||
std.Script = Sc_GetAPI();
|
||||
|
||||
std.strnupr = com_strnupr;
|
||||
std.strnlwr = com_strnlwr;
|
||||
std.strupr = com_strupr;
|
||||
std.strlwr = com_strlwr;
|
||||
std.strlen = com_strlen;
|
||||
std.cstrlen = com_cstrlen;
|
||||
std.toupper = com_toupper;
|
||||
std.tolower = com_tolower;
|
||||
std.strncat = com_strncat;
|
||||
std.strcat = com_strcat;
|
||||
std.strncpy = com_strncpy;
|
||||
std.strcpy = com_strcpy;
|
||||
std.stralloc = com_stralloc;
|
||||
std.atoi = com_atoi;
|
||||
std.atof = com_atof;
|
||||
std.atov = com_atov;
|
||||
std.strchr = com_strchr;
|
||||
std.strrchr = com_strrchr;
|
||||
std.strnicmp = com_strnicmp;
|
||||
std.stricmp = com_stricmp;
|
||||
std.strncmp = com_strncmp;
|
||||
std.strcmp = com_strcmp;
|
||||
std.stristr = com_stristr;
|
||||
std.strstr = com_stristr; // FIXME
|
||||
std.strpack = com_strpack;
|
||||
std.strunpack = com_strunpack;
|
||||
std.vsprintf = com_vsprintf;
|
||||
std.sprintf = com_sprintf;
|
||||
std.va = va;
|
||||
std.vsnprintf = com_vsnprintf;
|
||||
std.snprintf = com_snprintf;
|
||||
|
||||
std.LoadLibrary = Sys_LoadLibrary;
|
||||
std.FreeLibrary = Sys_FreeLibrary;
|
||||
std.GetProcAddress = Sys_GetProcAddress;
|
||||
|
||||
return &std;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
CommonInit
|
||||
|
||||
platform.dll needs for some setup operations
|
||||
so do it manually
|
||||
==================
|
||||
*/
|
||||
void CommonInit ( char *funcname, int argc, char **argv )
|
||||
{
|
||||
byte bspflags = 0, qccflags = 0, roqflags = 0;
|
||||
char source[64], gamedir[64];
|
||||
|
||||
Com->Init( argc, argv );
|
||||
|
||||
switch(sys.app_name)
|
||||
{
|
||||
case BSPLIB:
|
||||
if(!FS_GetParmFromCmdLine("-game", gamedir ))
|
||||
com_strncpy(gamedir, "xash", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+map", source ))
|
||||
com_strncpy(source, "newmap", sizeof(source));
|
||||
if(FS_CheckParm("-vis")) bspflags |= BSP_ONLYVIS;
|
||||
if(FS_CheckParm("-rad")) bspflags |= BSP_ONLYRAD;
|
||||
if(FS_CheckParm("-full")) bspflags |= BSP_FULLCOMPILE;
|
||||
if(FS_CheckParm("-onlyents")) bspflags |= BSP_ONLYENTS;
|
||||
|
||||
Com->Compile.PrepareBSP( gamedir, source, bspflags );
|
||||
break;
|
||||
case QCCLIB:
|
||||
if(!FS_GetParmFromCmdLine("-dir", gamedir ))
|
||||
com_strncpy(gamedir, ".", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+src", source ))
|
||||
com_strncpy(source, "progs.src", sizeof(source));
|
||||
if(FS_CheckParm("-progdefs")) qccflags |= QCC_PROGDEFS;
|
||||
if(FS_CheckParm("/O0")) qccflags |= QCC_OPT_LEVEL_0;
|
||||
if(FS_CheckParm("/O1")) qccflags |= QCC_OPT_LEVEL_1;
|
||||
if(FS_CheckParm("/O2")) qccflags |= QCC_OPT_LEVEL_2;
|
||||
if(FS_CheckParm("/O3")) qccflags |= QCC_OPT_LEVEL_3;
|
||||
|
||||
sys.start = Sys_DoubleTime();
|
||||
Com->Compile.PrepareDAT( gamedir, source, qccflags );
|
||||
break;
|
||||
case ROQLIB:
|
||||
if(!FS_GetParmFromCmdLine("-dir", gamedir ))
|
||||
com_strncpy(gamedir, ".", sizeof(gamedir));
|
||||
if(!FS_GetParmFromCmdLine("+src", source ))
|
||||
com_strncpy(source, "makefile.qc", sizeof(source));
|
||||
|
||||
sys.start = Sys_DoubleTime();
|
||||
Com->Compile.PrepareROQ( gamedir, source, roqflags );
|
||||
break;
|
||||
case IMGLIB:
|
||||
case SPRITE:
|
||||
case STUDIO:
|
||||
FS_InitRootDir(".");
|
||||
sys.start = Sys_DoubleTime();
|
||||
break;
|
||||
case DEFAULT:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CommonMain ( void )
|
||||
{
|
||||
search_t *search;
|
||||
bool (*CompileMod)( byte *mempool, const char *name, byte parms ) = NULL;
|
||||
char filename[MAX_QPATH], typemod[16], searchmask[8][16], errorstring[256];
|
||||
byte parms = 0; // future expansion
|
||||
int i, j, numCompiledMods = 0;
|
||||
|
||||
Mem_Set( searchmask, 0, 8 * 16 );
|
||||
Mem_Set( errorstring, 0, 256 );
|
||||
|
||||
switch(sys.app_name)
|
||||
{
|
||||
case SPRITE:
|
||||
CompileMod = Com->Compile.Sprite;
|
||||
com_strcpy(typemod, "sprites" );
|
||||
com_strcpy(searchmask[0], "*.qc" );
|
||||
break;
|
||||
case STUDIO:
|
||||
CompileMod = Com->Compile.Studio;
|
||||
com_strcpy(typemod, "models" );
|
||||
com_strcpy(searchmask[0], "*.qc" );
|
||||
break;
|
||||
case IMGLIB:
|
||||
CompileMod = Com->Compile.Image;
|
||||
com_strcpy(typemod, "images" );
|
||||
com_strcpy(searchmask[0], "*.pcx" ); // quake2 menu images
|
||||
com_strcpy(searchmask[1], "*.wal" ); // quake2 textures
|
||||
com_strcpy(searchmask[2], "*.lmp" ); // quake1 menu images
|
||||
com_strcpy(searchmask[3], "*.mip" ); // quake1 textures
|
||||
Msg("Processing images ...\n\n");
|
||||
break;
|
||||
case BSPLIB:
|
||||
com_strcpy(typemod, "maps" );
|
||||
com_strcpy(searchmask[0], "*.map" );
|
||||
Com->Compile.BSP();
|
||||
break;
|
||||
case QCCLIB:
|
||||
com_strcpy(typemod, "progs" );
|
||||
com_strcpy(searchmask[0], "*.src" );
|
||||
com_strcpy(searchmask[1], "*.qc" ); // no longer used
|
||||
Com->Compile.DAT();
|
||||
break;
|
||||
case ROQLIB:
|
||||
com_strcpy(typemod, "videos" );
|
||||
com_strcpy(searchmask[0], "*.qc" );
|
||||
Com->Compile.ROQ();
|
||||
break;
|
||||
case DEFAULT:
|
||||
com_strcpy(typemod, "things" );
|
||||
com_strcpy(searchmask[0], "*.*" );
|
||||
break;
|
||||
}
|
||||
if(!CompileMod) goto elapced_time;//back to shutdown
|
||||
|
||||
sys.zonepool = Mem_AllocPool("compiler");
|
||||
if(!FS_GetParmFromCmdLine("-file", filename ))
|
||||
{
|
||||
//search by mask
|
||||
for( i = 0; i < 8; i++)
|
||||
{
|
||||
// skip blank mask
|
||||
if(!com_strlen(searchmask[i])) continue;
|
||||
search = FS_Search( searchmask[i], true );
|
||||
if(!search) continue; // try next mask
|
||||
|
||||
for( j = 0; j < search->numfilenames; j++ )
|
||||
{
|
||||
if(CompileMod( sys.zonepool, search->filenames[j], parms ))
|
||||
numCompiledMods++;
|
||||
}
|
||||
}
|
||||
if(numCompiledMods == 0)
|
||||
{
|
||||
for(j = 0; j < 8; j++) com_strcat(errorstring, searchmask[j]);
|
||||
Sys_Error("no %s found in this folder!\n", errorstring );
|
||||
}
|
||||
}
|
||||
else CompileMod( sys.zonepool, filename, parms );
|
||||
|
||||
elapced_time:
|
||||
sys.end = Sys_DoubleTime();
|
||||
Msg ("%5.3f seconds elapsed\n", sys.end - sys.start);
|
||||
if(numCompiledMods > 1) Msg("total %d %s compiled\n", numCompiledMods, typemod );
|
||||
}
|
||||
|
||||
void CommonShutdown ( void )
|
||||
{
|
||||
Mem_Check(); //check for leaks
|
||||
Mem_FreePool( &sys.zonepool );
|
||||
Com->Shutdown();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
Find needed library, setup and run it
|
||||
==================
|
||||
*/
|
||||
void CreateInstance( void )
|
||||
{
|
||||
// export
|
||||
common_t CreateCom;
|
||||
launch_t CreateHost;
|
||||
|
||||
// first text message into console or log
|
||||
MsgDev(D_INFO, "Sys_LoadLibrary: Loading launch.dll - ok\n" );
|
||||
Sys_LoadLibrary( sys.linked_dll ); // loading library if need
|
||||
|
||||
switch(sys.app_name)
|
||||
{
|
||||
case HOST_SHARED:
|
||||
case HOST_DEDICATED:
|
||||
case HOST_EDITOR:
|
||||
CreateHost = (void *)sys.linked_dll->main;
|
||||
|
||||
// set callback
|
||||
Host = CreateHost( Get_StdAPI());
|
||||
sys.Init = Host->Init;
|
||||
sys.Main = Host->Main;
|
||||
sys.Free = Host->Free;
|
||||
break;
|
||||
case BSPLIB:
|
||||
case QCCLIB:
|
||||
case ROQLIB:
|
||||
case IMGLIB:
|
||||
case SPRITE:
|
||||
case STUDIO:
|
||||
CreateCom = (void *)sys.linked_dll->main;
|
||||
|
||||
// set callback
|
||||
Com = CreateCom(Get_StdAPI());
|
||||
sys.Init = CommonInit;
|
||||
sys.Main = CommonMain;
|
||||
sys.Free = CommonShutdown;
|
||||
break;
|
||||
case CREDITS:
|
||||
Sys_Print( show_credits );
|
||||
Sys_WaitForQuit();
|
||||
Sys_Exit();
|
||||
break;
|
||||
case HOST_INSTALL:
|
||||
// FS_UpdateEnvironmentVariables() is done, quit now
|
||||
Sys_Exit();
|
||||
break;
|
||||
case DEFAULT:
|
||||
Sys_Error("CreateInstance: unsupported instance\n");
|
||||
break;
|
||||
}
|
||||
|
||||
// init our host now!
|
||||
sys.Init( sys.progname, fs_argc, fs_argv );
|
||||
|
||||
// hide console if needed
|
||||
switch(sys.app_name)
|
||||
{
|
||||
case HOST_SHARED:
|
||||
case HOST_EDITOR:
|
||||
Con_ShowConsole( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Base Entry Point
|
||||
|
@ -335,12 +13,11 @@ Base Entry Point
|
|||
DLLEXPORT int CreateAPI( char *funcname )
|
||||
{
|
||||
// memeber name
|
||||
com_strncpy( sys.progname, funcname, sizeof(sys.progname));
|
||||
com_strncpy( Sys.progname, funcname, sizeof(Sys.progname));
|
||||
|
||||
Sys_Init();
|
||||
CreateInstance();
|
||||
sys.Main(); // ok, starting host
|
||||
Sys_Exit(); // normal quit from appilcation
|
||||
Sys.Main();
|
||||
Sys_Exit();
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -389,11 +389,13 @@ Memory_Init
|
|||
*/
|
||||
void Memory_Init( void )
|
||||
{
|
||||
poolchain = NULL;//init mem chain
|
||||
sys.basepool = Mem_AllocPool( "Main pool" );
|
||||
poolchain = NULL; // init mem chain
|
||||
Sys.basepool = Mem_AllocPool( "Main pool" );
|
||||
Sys.imagepool = Mem_AllocPool( "ImageLib Pool" );
|
||||
}
|
||||
|
||||
void Memory_Shutdown( void )
|
||||
{
|
||||
Mem_FreePool( &sys.basepool );
|
||||
Mem_FreePool( &Sys.basepool );
|
||||
Mem_FreePool( &Sys.imagepool );
|
||||
}
|
|
@ -17,7 +17,6 @@ typedef struct
|
|||
// max included scripts
|
||||
#define MAX_INCLUDES 32
|
||||
|
||||
static scriptsystem_api_t sc;
|
||||
script_t scriptstack[ MAX_INCLUDES ];
|
||||
script_t *script;
|
||||
int scriptline;
|
||||
|
@ -126,7 +125,7 @@ skip_whitespace: // skip whitespace
|
|||
// ets++
|
||||
if (*script->script_p == '/') script->script_p++;
|
||||
if (script->script_p[1] == 'T' && script->script_p[2] == 'X')
|
||||
sc.g_TXcommand = script->script_p[3];//TX#"-style comment
|
||||
std.com_TXcommand = script->script_p[3];//TX#"-style comment (get rid of this)
|
||||
while (*script->script_p++ != '\n')
|
||||
{
|
||||
if (script->script_p >= script->end_p)
|
||||
|
@ -727,30 +726,4 @@ bool SC_FilterToken(char *filter, char *name, int casecmp)
|
|||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=============================================================================
|
||||
|
||||
EXTERNAL PARSE STUFF INTERFACE
|
||||
=============================================================================
|
||||
*/
|
||||
scriptsystem_api_t Sc_GetAPI( void )
|
||||
{
|
||||
sc.api_size = sizeof(scriptsystem_api_t);
|
||||
|
||||
sc.Load = SC_LoadScript;
|
||||
sc.Include = SC_AddScript;
|
||||
sc.Reset = SC_ResetScript;
|
||||
sc.GetToken = SC_GetToken;
|
||||
sc.TryToken = SC_TryToken;
|
||||
sc.FreeToken = SC_FreeToken;
|
||||
sc.SkipToken = SC_SkipToken;
|
||||
sc.MatchToken = SC_MatchToken;
|
||||
sc.ParseToken = SC_ParseToken;
|
||||
sc.ParseWord = SC_ParseWord;
|
||||
sc.FilterToken = SC_FilterToken;
|
||||
sc.Token = token;
|
||||
|
||||
return sc;
|
||||
}
|
|
@ -185,7 +185,7 @@ char *com_stralloc(const char *s)
|
|||
{
|
||||
char *b;
|
||||
|
||||
b = Mem_Alloc(sys.basepool, com_strlen(s) + 1 );
|
||||
b = Mem_Alloc(Sys.basepool, com_strlen(s) + 1 );
|
||||
com_strcpy(b, s);
|
||||
|
||||
return b;
|
||||
|
|
|
@ -7,14 +7,19 @@
|
|||
#include "launch.h"
|
||||
#include "basemath.h"
|
||||
|
||||
system_t sys;
|
||||
FILE *logfile;
|
||||
system_t Sys;
|
||||
stdlib_api_t std;
|
||||
launch_exp_t *Host; // callback to mainframe
|
||||
FILE *logfile;
|
||||
|
||||
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(common_exp_t) };
|
||||
dll_info_t common_dll = { "common.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(launch_exp_t) };
|
||||
dll_info_t engine_dll = { "engine.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(launch_exp_t) };
|
||||
dll_info_t editor_dll = { "editor.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(launch_exp_t) };
|
||||
|
||||
void NullInit ( char *funcname, int argc, char **argv )
|
||||
static const char *show_credits = "\n\n\n\n\tCopyright XashXT Group 2007 ©\n\t\
|
||||
All Rights Reserved\n\n\t Visit www.xash.ru\n";
|
||||
|
||||
void NullInit ( uint funcname, int argc, char **argv )
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -27,6 +32,145 @@ gameinfo_t Sys_GameInfo( void )
|
|||
return GI;
|
||||
}
|
||||
|
||||
void Sys_GetStdAPI( void )
|
||||
{
|
||||
// interface validator
|
||||
std.api_size = sizeof(stdlib_api_t);
|
||||
|
||||
// base events
|
||||
std.printf = Sys_Msg;
|
||||
std.dprintf = Sys_MsgDev;
|
||||
std.wprintf = Sys_MsgWarn;
|
||||
std.error = Sys_Error;
|
||||
std.exit = Sys_Exit;
|
||||
std.print = Sys_Print;
|
||||
std.input = Sys_Input;
|
||||
std.sleep = Sys_Sleep;
|
||||
std.clipboard = Sys_GetClipboardData;
|
||||
std.keyevents = Sys_SendKeyEvents;
|
||||
|
||||
// crclib.c funcs
|
||||
std.crc_init = CRC_Init;
|
||||
std.crc_block = CRC_Block;
|
||||
std.crc_process = CRC_ProcessByte;
|
||||
std.crc_sequence = CRC_BlockSequence;
|
||||
|
||||
// memlib.c
|
||||
std.memcpy = _mem_copy;
|
||||
std.memset = _mem_set;
|
||||
std.realloc = _mem_realloc;
|
||||
std.move = _mem_move;
|
||||
std.malloc = _mem_alloc;
|
||||
std.free = _mem_free;
|
||||
std.mallocpool = _mem_allocpool;
|
||||
std.freepool = _mem_freepool;
|
||||
std.clearpool = _mem_emptypool;
|
||||
std.memcheck = _mem_check;
|
||||
|
||||
// common functions
|
||||
std.Com_InitRootDir = FS_InitRootDir; // init custom rootdir
|
||||
std.Com_LoadGameInfo = FS_LoadGameInfo; // gate game info from script file
|
||||
std.Com_AddGameHierarchy = FS_AddGameHierarchy; // add base directory in search list
|
||||
std.Com_CheckParm = FS_CheckParm; // get parm from cmdline
|
||||
std.Com_GetParm = FS_GetParmFromCmdLine; // get filename without path & ext
|
||||
std.Com_FileBase = FS_FileBase; // get filename without path & ext
|
||||
std.Com_FileExists = FS_FileExists; // return true if file exist
|
||||
std.Com_FileSize = FS_FileSize; // same as Com_FileExists but return filesize
|
||||
std.Com_FileExtension = FS_FileExtension; // return extension of file
|
||||
std.Com_RemovePath = FS_FileWithoutPath; // return file without path
|
||||
std.Com_StripExtension = FS_StripExtension; // remove extension if present
|
||||
std.Com_StripFilePath = FS_ExtractFilePath; // get file path without filename.ext
|
||||
std.Com_DefaultExtension = FS_DefaultExtension; // append extension if not present
|
||||
std.Com_ClearSearchPath = FS_ClearSearchPath; // delete all search pathes
|
||||
std.Com_CreateThread = Sys_RunThreadsOnIndividual;// run individual thread
|
||||
std.Com_ThreadLock = Sys_ThreadLock; // lock current thread
|
||||
std.Com_ThreadUnlock = Sys_ThreadUnlock; // unlock numthreads
|
||||
std.Com_NumThreads = Sys_GetNumThreads; // returns count of active threads
|
||||
std.Com_LoadScript = SC_LoadScript; // load script into stack from file or bufer
|
||||
std.Com_AddScript = SC_AddScript; // include script from file or buffer
|
||||
std.Com_ResetScript = SC_ResetScript; // reset current script state
|
||||
std.Com_ReadToken = SC_GetToken; // get next token on a line or newline
|
||||
std.Com_TryToken = SC_TryToken; // return 1 if have token on a line
|
||||
std.Com_FreeToken = SC_FreeToken; // free current token to may get it again
|
||||
std.Com_SkipToken = SC_SkipToken; // skip current token and jump into newline
|
||||
std.Com_MatchToken = SC_MatchToken; // compare current token with user keyword
|
||||
std.Com_ParseToken = SC_ParseToken; // parse token from char buffer
|
||||
std.Com_ParseWord = SC_ParseWord; // parse word from char buffer
|
||||
std.Com_Search = FS_Search; // returned list of found files
|
||||
std.Com_Filter = SC_FilterToken; // compare keyword by mask with filter
|
||||
std.com_token = token; // contains current token
|
||||
|
||||
// real filesystem
|
||||
std.fopen = FS_Open; // same as fopen
|
||||
std.fclose = FS_Close; // same as fclose
|
||||
std.fwrite = FS_Write; // same as fwrite
|
||||
std.fread = FS_Read; // same as fread, can see trough pakfile
|
||||
std.fprint = FS_Print; // printed message into file
|
||||
std.fprintf = FS_Printf; // same as fprintf
|
||||
std.fgets = FS_Gets; // like a fgets, but can return EOF
|
||||
std.fseek = FS_Seek; // fseek, can seek in packfiles too
|
||||
std.ftell = FS_Tell; // like a ftell
|
||||
|
||||
// virtual filesystem
|
||||
std.vfcreate = VFS_Create; // create virtual stream
|
||||
std.vfopen = VFS_Open; // virtual fopen
|
||||
std.vfclose = VFS_Close; // free buffer or write dump
|
||||
std.vfwrite = VFS_Write; // write into buffer
|
||||
std.vfwrite2 = VFS_Write2; // deflate buffer, then write
|
||||
std.vfread = VFS_Read; // read from buffer
|
||||
std.vfseek = VFS_Seek; // fseek, can seek in packfiles too
|
||||
std.vfunpack = VFS_Unpack; // inflate zipped buffer
|
||||
std.vftell = VFS_Tell; // like a ftell
|
||||
|
||||
// filesystem simply user interface
|
||||
std.Com_LoadFile = FS_LoadFile; // load file into heap
|
||||
std.Com_WriteFile = FS_WriteFile; // write file into disk
|
||||
std.Com_LoadImage = FS_LoadImage; // extract image into rgba buffer
|
||||
std.Com_SaveImage = FS_SaveImage; // save image into specified format
|
||||
std.Com_ProcessImage = Image_Processing; // convert and resample image
|
||||
std.Com_FreeImage = FS_FreeImage; // free image buffer
|
||||
std.Com_LoadLibrary = Sys_LoadLibrary; // load library
|
||||
std.Com_FreeLibrary = Sys_FreeLibrary; // free library
|
||||
std.Com_GetProcAddress = Sys_GetProcAddress; // gpa
|
||||
std.Com_DoubleTime = Sys_DoubleTime; // hi-res timer
|
||||
|
||||
// stdlib.c funcs
|
||||
std.strnupr = com_strnupr;
|
||||
std.strnlwr = com_strnlwr;
|
||||
std.strupr = com_strupr;
|
||||
std.strlwr = com_strlwr;
|
||||
std.strlen = com_strlen;
|
||||
std.cstrlen = com_cstrlen;
|
||||
std.toupper = com_toupper;
|
||||
std.tolower = com_tolower;
|
||||
std.strncat = com_strncat;
|
||||
std.strcat = com_strcat;
|
||||
std.strncpy = com_strncpy;
|
||||
std.strcpy = com_strcpy;
|
||||
std.stralloc = com_stralloc;
|
||||
std.atoi = com_atoi;
|
||||
std.atof = com_atof;
|
||||
std.atov = com_atov;
|
||||
std.strchr = com_strchr;
|
||||
std.strrchr = com_strrchr;
|
||||
std.strnicmp = com_strnicmp;
|
||||
std.stricmp = com_stricmp;
|
||||
std.strncmp = com_strncmp;
|
||||
std.strcmp = com_strcmp;
|
||||
std.stristr = com_stristr;
|
||||
std.strstr = com_stristr; // FIXME
|
||||
std.strpack = com_strpack;
|
||||
std.strunpack = com_strunpack;
|
||||
std.vsprintf = com_vsprintf;
|
||||
std.sprintf = com_sprintf;
|
||||
std.va = va;
|
||||
std.vsnprintf = com_vsnprintf;
|
||||
std.snprintf = com_snprintf;
|
||||
std.timestamp = com_timestamp;
|
||||
|
||||
std.GameInfo = &GI;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Parse program name to launch and determine work style
|
||||
|
@ -50,95 +194,151 @@ This list will be expnaded in future
|
|||
*/
|
||||
void Sys_LookupInstance( void )
|
||||
{
|
||||
Sys.app_name = HOST_OFFLINE;
|
||||
|
||||
// lookup all instances
|
||||
if(!com_strcmp(sys.progname, "host_shared"))
|
||||
if(!com_strcmp(Sys.progname, "host_shared"))
|
||||
{
|
||||
sys.app_name = HOST_SHARED;
|
||||
sys.con_readonly = true;
|
||||
Sys.app_name = HOST_NORMAL;
|
||||
Sys.con_readonly = true;
|
||||
// don't show console as default
|
||||
if(!Sys.debug) Sys.con_showalways = false;
|
||||
Sys.linked_dll = &engine_dll; // pointer to engine.dll info
|
||||
com_strcpy(Sys.log_path, "engine.log" ); // xash3d root directory
|
||||
com_strcpy(Sys.caption, va("Xash3D ver.%g", XASH_VERSION ));
|
||||
}
|
||||
else if(!com_strcmp(Sys.progname, "host_dedicated"))
|
||||
{
|
||||
Sys.app_name = HOST_DEDICATED;
|
||||
Sys.con_readonly = false;
|
||||
Sys.linked_dll = &engine_dll; // pointer to engine.dll info
|
||||
com_strcpy(Sys.log_path, "engine.log" ); // xash3d root directory
|
||||
com_strcpy(Sys.caption, va("Xash3D Dedicated Server ver.%g", XASH_VERSION ));
|
||||
}
|
||||
else if(!com_strcmp(Sys.progname, "host_editor"))
|
||||
{
|
||||
Sys.app_name = HOST_EDITOR;
|
||||
Sys.con_readonly = true;
|
||||
//don't show console as default
|
||||
if(!sys.debug) sys.con_showalways = false;
|
||||
sys.linked_dll = &engine_dll; // pointer to engine.dll info
|
||||
com_strcpy(sys.log_path, "engine.log" ); // xash3d root directory
|
||||
com_strcpy(sys.caption, va("Xash3D ver.%g", XASH_VERSION ));
|
||||
if(!Sys.debug) Sys.con_showalways = false;
|
||||
Sys.linked_dll = &editor_dll; // pointer to editor.dll info
|
||||
com_strcpy(Sys.log_path, "editor.log" ); // xash3d root directory
|
||||
com_strcpy(Sys.caption, va("Xash3D Editor ver.%g", XASH_VERSION ));
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "host_dedicated"))
|
||||
else if(!com_strcmp(Sys.progname, "bsplib"))
|
||||
{
|
||||
sys.app_name = HOST_DEDICATED;
|
||||
sys.con_readonly = false;
|
||||
sys.linked_dll = &engine_dll; // pointer to engine.dll info
|
||||
com_strcpy(sys.log_path, "engine.log" ); // xash3d root directory
|
||||
com_strcpy(sys.caption, va("Xash3D Dedicated Server ver.%g", XASH_VERSION ));
|
||||
Sys.app_name = BSPLIB;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_strcpy(Sys.log_path, "bsplib.log" ); // xash3d root directory
|
||||
com_strcpy(Sys.caption, "Xash3D BSP Compiler");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "host_editor"))
|
||||
else if(!com_strcmp(Sys.progname, "imglib"))
|
||||
{
|
||||
sys.app_name = HOST_EDITOR;
|
||||
sys.con_readonly = true;
|
||||
//don't show console as default
|
||||
if(!sys.debug) sys.con_showalways = false;
|
||||
sys.linked_dll = &editor_dll; // pointer to editor.dll info
|
||||
com_strcpy(sys.log_path, "editor.log" ); // xash3d root directory
|
||||
com_strcpy(sys.caption, va("Xash3D Editor ver.%g", XASH_VERSION ));
|
||||
Sys.app_name = IMGLIB;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(Sys.log_path, "%s/convert.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(Sys.caption, "Xash3D Image Converter");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "bsplib"))
|
||||
else if(!com_strcmp(Sys.progname, "qcclib"))
|
||||
{
|
||||
sys.app_name = BSPLIB;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_strcpy(sys.log_path, "bsplib.log" ); // xash3d root directory
|
||||
com_strcpy(sys.caption, "Xash3D BSP Compiler");
|
||||
Sys.app_name = QCCLIB;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(Sys.log_path, "%s/compile.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(Sys.caption, "Xash3D QuakeC Compiler");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "imglib"))
|
||||
else if(!com_strcmp(Sys.progname, "roqlib"))
|
||||
{
|
||||
sys.app_name = IMGLIB;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(sys.log_path, "%s/convert.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(sys.caption, "Xash3D Image Converter");
|
||||
Sys.app_name = ROQLIB;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(Sys.log_path, "%s/roq.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(Sys.caption, "Xash3D ROQ Video Maker");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "qcclib"))
|
||||
else if(!com_strcmp(Sys.progname, "sprite"))
|
||||
{
|
||||
sys.app_name = QCCLIB;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(sys.log_path, "%s/compile.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(sys.caption, "Xash3D QuakeC Compiler");
|
||||
Sys.app_name = SPRITE;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(Sys.log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(Sys.caption, "Xash3D Sprite Compiler");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "roqlib"))
|
||||
else if(!com_strcmp(Sys.progname, "studio"))
|
||||
{
|
||||
sys.app_name = ROQLIB;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(sys.log_path, "%s/roq.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(sys.caption, "Xash3D ROQ Video Maker");
|
||||
Sys.app_name = STUDIO;
|
||||
Sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(Sys.log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(Sys.caption, "Xash3D Studio Models Compiler");
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "sprite"))
|
||||
else if(!com_strcmp(Sys.progname, "credits")) // easter egg
|
||||
{
|
||||
sys.app_name = SPRITE;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(sys.log_path, "%s/spritegen.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(sys.caption, "Xash3D Sprite Compiler");
|
||||
Sys.app_name = CREDITS;
|
||||
Sys.linked_dll = NULL; // no need to loading library
|
||||
Sys.log_active = Sys.developer = Sys.debug = 0; // clear all dbg states
|
||||
com_strcpy(Sys.caption, "About");
|
||||
Sys.con_showcredits = true;
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "studio"))
|
||||
else if(!com_strcmp(Sys.progname, "host_setup")) // write path into registry
|
||||
{
|
||||
sys.app_name = STUDIO;
|
||||
sys.linked_dll = &common_dll; // pointer to common.dll info
|
||||
com_sprintf(sys.log_path, "%s/studiomdl.log", sys_rootdir ); // same as .exe file
|
||||
com_strcpy(sys.caption, "Xash3D Studio Models Compiler");
|
||||
Sys.app_name = HOST_INSTALL;
|
||||
Sys.linked_dll = NULL; // no need to loading library
|
||||
Sys.log_active = Sys.developer = Sys.debug = 0; //clear all dbg states
|
||||
Sys.con_silentmode = true;
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "credits")) // easter egg
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
Find needed library, setup and run it
|
||||
==================
|
||||
*/
|
||||
void Sys_CreateInstance( void )
|
||||
{
|
||||
// export
|
||||
launch_t CreateHost;
|
||||
|
||||
Sys_LoadLibrary( Sys.linked_dll ); // loading library if need
|
||||
|
||||
switch(Sys.app_name)
|
||||
{
|
||||
sys.app_name = CREDITS;
|
||||
sys.linked_dll = NULL; // no need to loading library
|
||||
sys.log_active = sys.developer = sys.debug = 0; // clear all dbg states
|
||||
com_strcpy(sys.caption, "About");
|
||||
sys.con_showcredits = true;
|
||||
case HOST_NORMAL:
|
||||
case HOST_DEDICATED:
|
||||
case HOST_EDITOR:
|
||||
case BSPLIB:
|
||||
case QCCLIB:
|
||||
case ROQLIB:
|
||||
case IMGLIB:
|
||||
case SPRITE:
|
||||
case STUDIO:
|
||||
CreateHost = (void *)Sys.linked_dll->main;
|
||||
|
||||
// set callback
|
||||
Host = CreateHost( &std, NULL ); // second interface not allowed
|
||||
Sys.Init = Host->Init;
|
||||
Sys.Main = Host->Main;
|
||||
Sys.Free = Host->Free;
|
||||
break;
|
||||
case CREDITS:
|
||||
Sys_Print( show_credits );
|
||||
Sys_WaitForQuit();
|
||||
Sys_Exit();
|
||||
break;
|
||||
case HOST_INSTALL:
|
||||
// FS_UpdateEnvironmentVariables() is done, quit now
|
||||
Sys_Exit();
|
||||
break;
|
||||
case HOST_OFFLINE:
|
||||
Sys_Error("Host offline\n Press \"ESC\" to exit\n");
|
||||
break;
|
||||
}
|
||||
else if(!com_strcmp(sys.progname, "host_setup")) // write path into registry
|
||||
|
||||
// init our host now!
|
||||
Sys.Init( Sys.app_name, fs_argc, fs_argv );
|
||||
|
||||
// hide console if needed
|
||||
switch(Sys.app_name)
|
||||
{
|
||||
sys.app_name = HOST_INSTALL;
|
||||
sys.linked_dll = NULL; // no need to loading library
|
||||
sys.log_active = sys.developer = sys.debug = 0; //clear all dbg states
|
||||
sys.con_silentmode = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
sys.app_name = DEFAULT;
|
||||
case HOST_NORMAL:
|
||||
case HOST_EDITOR:
|
||||
Con_ShowConsole( false );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -201,12 +401,12 @@ void Sys_ParseCommandLine (LPSTR lpCmdLine)
|
|||
void Sys_InitLog( void )
|
||||
{
|
||||
// create log if needed
|
||||
if(!sys.log_active || !com_strlen(sys.log_path) || sys.con_silentmode) return;
|
||||
logfile = fopen( sys.log_path, "w");
|
||||
if(!logfile) Sys_Error("Sys_InitLog: can't create log file %s\n", sys.log_path );
|
||||
if(!Sys.log_active || !com_strlen(Sys.log_path) || Sys.con_silentmode) return;
|
||||
logfile = fopen( Sys.log_path, "w");
|
||||
if(!logfile) Sys_Error("Sys_InitLog: can't create log file %s\n", Sys.log_path );
|
||||
|
||||
fprintf(logfile, "=======================================================================\n" );
|
||||
fprintf(logfile, "\t%s started at %s\n", sys.caption, com_timestamp(TIME_FULL));
|
||||
fprintf(logfile, "\t%s started at %s\n", Sys.caption, com_timestamp(TIME_FULL));
|
||||
fprintf(logfile, "=======================================================================\n");
|
||||
}
|
||||
|
||||
|
@ -216,7 +416,7 @@ void Sys_CloseLog( void )
|
|||
|
||||
fprintf(logfile, "\n");
|
||||
fprintf(logfile, "=======================================================================");
|
||||
fprintf(logfile, "\n\t%s stopped at %s\n", sys.caption, com_timestamp(TIME_FULL));
|
||||
fprintf(logfile, "\n\t%s stopped at %s\n", Sys.caption, com_timestamp(TIME_FULL));
|
||||
fprintf(logfile, "=======================================================================");
|
||||
|
||||
fclose(logfile);
|
||||
|
@ -245,7 +445,7 @@ void Sys_Print(const char *pMsg)
|
|||
char *c = logbuf;
|
||||
int i = 0;
|
||||
|
||||
if(sys.con_silentmode) return;
|
||||
if(Sys.con_silentmode) return;
|
||||
|
||||
// if the message is REALLY long, use just the last portion of it
|
||||
if ( com_strlen( pMsg ) > MAX_INPUTLINE - 1 )
|
||||
|
@ -289,7 +489,7 @@ void Sys_Print(const char *pMsg)
|
|||
*b = *c = 0; // cutoff garbage
|
||||
|
||||
Sys_PrintLog( logbuf );
|
||||
if(sys.Con_Print) sys.Con_Print( buffer );
|
||||
if(Sys.Con_Print) Sys.Con_Print( buffer );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -316,7 +516,7 @@ void Sys_MsgDev( int level, const char *pMsg, ... )
|
|||
va_list argptr;
|
||||
char text[MAX_INPUTLINE];
|
||||
|
||||
if(sys.developer < level) return;
|
||||
if(Sys.developer < level) return;
|
||||
|
||||
va_start (argptr, pMsg);
|
||||
com_vsprintf (text, pMsg, argptr);
|
||||
|
@ -329,7 +529,7 @@ void Sys_MsgWarn( const char *pMsg, ... )
|
|||
va_list argptr;
|
||||
char text[MAX_INPUTLINE];
|
||||
|
||||
if(!sys.debug) return;
|
||||
if(!Sys.debug) return;
|
||||
|
||||
va_start (argptr, pMsg);
|
||||
com_vsprintf (text, pMsg, argptr);
|
||||
|
@ -469,7 +669,7 @@ void Sys_WaitForQuit( void )
|
|||
{
|
||||
MSG msg;
|
||||
|
||||
if(sys.hooked_out)
|
||||
if(Sys.hooked_out)
|
||||
{
|
||||
Sys_Print("press any key to quit\n");
|
||||
getchar(); // wait for quit
|
||||
|
@ -505,13 +705,13 @@ void Sys_Error(char *error, ...)
|
|||
va_list argptr;
|
||||
char text[MAX_INPUTLINE];
|
||||
|
||||
if(sys.error) return; // don't multiple executes
|
||||
if(Sys.error) return; // don't multiple executes
|
||||
|
||||
va_start (argptr, error);
|
||||
com_vsprintf (text, error, argptr);
|
||||
va_end (argptr);
|
||||
|
||||
sys.error = true;
|
||||
Sys.error = true;
|
||||
|
||||
Con_ShowConsole( true );
|
||||
Sys_Print( text ); // print error message
|
||||
|
@ -525,11 +725,11 @@ long _stdcall Sys_ExecptionFilter( PEXCEPTION_POINTERS pExceptionInfo )
|
|||
{
|
||||
// save config
|
||||
Sys_Print("Engine crashed\n");
|
||||
sys.Free(); // prepare host to close
|
||||
Sys_FreeLibrary( sys.linked_dll );
|
||||
Sys.Free(); // prepare host to close
|
||||
Sys_FreeLibrary( Sys.linked_dll );
|
||||
Con_DestroyConsole();
|
||||
|
||||
if( sys.oldFilter ) return sys.oldFilter( pExceptionInfo );
|
||||
if( Sys.oldFilter ) return Sys.oldFilter( pExceptionInfo );
|
||||
|
||||
#if 1
|
||||
return EXCEPTION_CONTINUE_SEARCH;
|
||||
|
@ -588,40 +788,42 @@ void Sys_Init( void )
|
|||
//oldFilter = SetUnhandledExceptionFilter( Sys_ExecptionFilter );
|
||||
GlobalMemoryStatus (&lpBuffer);
|
||||
|
||||
sys.hInstance = (HINSTANCE)GetModuleHandle( NULL ); // get current hInstance first
|
||||
Sys.hInstance = (HINSTANCE)GetModuleHandle( NULL ); // get current hInstance first
|
||||
hStdout = GetStdHandle (STD_OUTPUT_HANDLE); // check for hooked out
|
||||
|
||||
if(!GetVersionEx (&vinfo)) Sys_ErrorFatal(ERR_OSINFO_FAIL);
|
||||
if(vinfo.dwMajorVersion < 4) Sys_ErrorFatal(ERR_INVALID_VER);
|
||||
if(vinfo.dwPlatformId == VER_PLATFORM_WIN32s) Sys_ErrorFatal(ERR_WINDOWS_32S);
|
||||
|
||||
sys.Init = NullInit;
|
||||
sys.Main = NullFunc;
|
||||
sys.Free = NullFunc;
|
||||
Sys_GetStdAPI();
|
||||
Sys.Init = NullInit;
|
||||
Sys.Main = NullFunc;
|
||||
Sys.Free = NullFunc;
|
||||
|
||||
// parse and copy args into local array
|
||||
Sys_ParseCommandLine(GetCommandLine());
|
||||
|
||||
if(FS_CheckParm ("-debug")) sys.debug = true;
|
||||
if(FS_CheckParm ("-log")) sys.log_active = true;
|
||||
if(FS_GetParmFromCmdLine("-dev", dev_level )) sys.developer = com_atoi(dev_level);
|
||||
if(FS_CheckParm ("-debug")) Sys.debug = true;
|
||||
if(FS_CheckParm ("-log")) Sys.log_active = true;
|
||||
if(FS_GetParmFromCmdLine("-dev", dev_level )) Sys.developer = com_atoi(dev_level);
|
||||
|
||||
// ugly hack to get pipeline state, but it works
|
||||
if(abs((short)hStdout) < 100) sys.hooked_out = false;
|
||||
else sys.hooked_out = true;
|
||||
if(abs((short)hStdout) < 100) Sys.hooked_out = false;
|
||||
else Sys.hooked_out = true;
|
||||
FS_UpdateEnvironmentVariables(); // set working directory
|
||||
|
||||
sys.con_showalways = true;
|
||||
sys.con_readonly = true;
|
||||
sys.con_showcredits = false;
|
||||
sys.con_silentmode = false;
|
||||
Sys.con_showalways = true;
|
||||
Sys.con_readonly = true;
|
||||
Sys.con_showcredits = false;
|
||||
Sys.con_silentmode = false;
|
||||
|
||||
Sys_InitCPU();
|
||||
Sys_LookupInstance(); // init launcher
|
||||
Con_CreateConsole();
|
||||
Sys_InitCPU();
|
||||
|
||||
Memory_Init();
|
||||
FS_Init();
|
||||
Sys_CreateInstance();
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -635,16 +837,16 @@ before call this
|
|||
void Sys_Exit ( void )
|
||||
{
|
||||
// prepare host to close
|
||||
sys.Free();
|
||||
Sys_FreeLibrary( sys.linked_dll );
|
||||
Sys.Free();
|
||||
Sys_FreeLibrary( Sys.linked_dll );
|
||||
|
||||
Con_DestroyConsole();
|
||||
FS_Shutdown();
|
||||
Memory_Shutdown();
|
||||
|
||||
if( sys.oldFilter ) // restore filter
|
||||
SetUnhandledExceptionFilter( sys.oldFilter );
|
||||
exit( sys.error );
|
||||
if( Sys.oldFilter ) // restore filter
|
||||
SetUnhandledExceptionFilter( Sys.oldFilter );
|
||||
exit( Sys.error );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
|
@ -708,7 +910,7 @@ bool Sys_LoadLibrary ( dll_info_t *dll )
|
|||
|
||||
// NOTE: native dlls must support null import!
|
||||
// e.g. see ..\common\platform.c for details
|
||||
check = (void *)dll->main( NULL );
|
||||
check = (void *)dll->main( &std, NULL ); // first iface always stdlib_api_t
|
||||
|
||||
if(!check)
|
||||
{
|
||||
|
|
|
@ -128,6 +128,10 @@ SOURCE=.\common\filesystem.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\imglib.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\launcher.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -23,22 +23,6 @@ enum
|
|||
ERR_WINDOWS_32S,
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
DEFAULT = 0, // host_init( funcname *arg ) same much as:
|
||||
HOST_SHARED, // "host_shared"
|
||||
HOST_DEDICATED, // "host_dedicated"
|
||||
HOST_EDITOR, // "host_editor"
|
||||
BSPLIB, // "bsplib"
|
||||
IMGLIB, // "imglib"
|
||||
QCCLIB, // "qcclib"
|
||||
ROQLIB, // "roqlib"
|
||||
SPRITE, // "sprite"
|
||||
STUDIO, // "studio"
|
||||
CREDITS, // "splash"
|
||||
HOST_INSTALL, // "install"
|
||||
};
|
||||
|
||||
typedef struct system_s
|
||||
{
|
||||
char progname[MAX_QPATH];
|
||||
|
@ -62,18 +46,20 @@ typedef struct system_s
|
|||
bool error;
|
||||
byte *basepool;
|
||||
byte *zonepool;
|
||||
byte *imagepool;
|
||||
|
||||
// simply profiling
|
||||
double start, end;
|
||||
|
||||
void (*Con_Print)( const char *msg );
|
||||
void ( *Init ) ( char *funcname, int argc, char **argv );
|
||||
void ( *Init ) ( uint funcname, int argc, char **argv );
|
||||
void ( *Main ) ( void ); // host frame
|
||||
void ( *Free ) ( void ); // close host
|
||||
} system_t;
|
||||
|
||||
extern system_t sys;
|
||||
extern system_t Sys;
|
||||
extern gameinfo_t GI;
|
||||
extern stdlib_api_t std;
|
||||
|
||||
//
|
||||
// console.c
|
||||
|
@ -188,17 +174,16 @@ void _mem_check(const char *filename, int fileline);
|
|||
#define Mem_AllocPool(name) _mem_allocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) _mem_freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) _mem_emptypool(pool, __FILE__, __LINE__)
|
||||
#define Mem_Move(dest, src, size ) _mem_move (dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Move(pool, dest, src, size ) _mem_move(pool, dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Copy(dest, src, size ) _mem_copy(dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Set(dest, src, size ) _mem_set(dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Check() _mem_check(__FILE__, __LINE__)
|
||||
|
||||
#define Malloc( size ) Mem_Alloc( sys.basepool, size )
|
||||
#define Malloc( size ) Mem_Alloc( Sys.basepool, size )
|
||||
|
||||
//
|
||||
// filesystem.c
|
||||
//
|
||||
filesystem_api_t FS_GetAPI( void );
|
||||
void FS_Init( void );
|
||||
void FS_Path( void );
|
||||
void FS_Shutdown( void );
|
||||
|
@ -212,7 +197,9 @@ void FS_FileBase (char *in, char *out);
|
|||
const char *FS_FileExtension (const char *in);
|
||||
void FS_DefaultExtension (char *path, const char *extension );
|
||||
bool FS_GetParmFromCmdLine( char *parm, char *out );
|
||||
void FS_ExtractFilePath(const char* const path, char* dest);
|
||||
void FS_UpdateEnvironmentVariables( void );
|
||||
const char *FS_FileWithoutPath (const char *in);
|
||||
extern char sys_rootdir[];
|
||||
extern char *fs_argv[];
|
||||
extern int fs_argc;
|
||||
|
@ -220,6 +207,10 @@ extern int fs_argc;
|
|||
// simply files managment interface
|
||||
byte *FS_LoadFile (const char *path, fs_offset_t *filesizeptr );
|
||||
bool FS_WriteFile (const char *filename, void *data, fs_offset_t len);
|
||||
rgbdata_t *FS_LoadImage(const char *filename, char *data, int size );
|
||||
void FS_SaveImage(const char *filename, rgbdata_t *buffer );
|
||||
void FS_FreeImage( rgbdata_t *pack );
|
||||
bool Image_Processing( const char *name, rgbdata_t **pix );
|
||||
search_t *FS_Search(const char *pattern, int caseinsensitive );
|
||||
search_t *FS_SearchDirs(const char *pattern, int caseinsensitive );
|
||||
|
||||
|
@ -244,11 +235,13 @@ int FS_Getc (file_t* file);
|
|||
bool FS_Eof( file_t* file);
|
||||
|
||||
// virtual files managment
|
||||
vfilesystem_api_t VFS_GetAPI( void );
|
||||
vfile_t *VFS_Create(byte *buffer, size_t buffsize);
|
||||
vfile_t *VFS_Open(const char *filename, const char* mode);
|
||||
fs_offset_t VFS_Write( vfile_t *file, const void *buf, size_t size );
|
||||
fs_offset_t VFS_Write2( vfile_t *handle, byte *buffer, size_t size );
|
||||
fs_offset_t VFS_Read(vfile_t* file, void* buffer, size_t buffersize);
|
||||
int VFS_Seek( vfile_t *file, fs_offset_t offset, int whence );
|
||||
bool VFS_Unpack( void* compbuf, size_t compsize, void **buf, size_t size );
|
||||
fs_offset_t VFS_Tell (vfile_t* file);
|
||||
int VFS_Close( vfile_t *file );
|
||||
|
||||
|
@ -263,16 +256,17 @@ byte CRC_BlockSequence(byte *base, int length, int sequence);
|
|||
//
|
||||
// parselib.c
|
||||
//
|
||||
scriptsystem_api_t Sc_GetAPI( void );
|
||||
bool SC_LoadScript( const char *filename, char *buf, int size );
|
||||
bool SC_AddScript( const char *filename, char *buf, int size );
|
||||
bool SC_FilterToken(char *filter, char *name, int casecmp);
|
||||
char *SC_ParseToken(const char **data_p );
|
||||
char *SC_ParseWord( const char **data_p );
|
||||
bool SC_MatchToken( const char *match );
|
||||
void SC_ResetScript( void );
|
||||
void SC_SkipToken( void );
|
||||
void SC_FreeToken( void );
|
||||
bool SC_TryToken( void );
|
||||
char *SC_GetToken( bool newline );
|
||||
char *SC_Token( void );
|
||||
extern char token[];
|
||||
|
||||
#endif//LAUNCHER_H
|
|
@ -6,6 +6,7 @@
|
|||
#include "physic.h"
|
||||
|
||||
physic_imp_t pi;
|
||||
stdlib_api_t std;
|
||||
byte *physpool;
|
||||
NewtonWorld *gWorld;
|
||||
|
||||
|
@ -23,14 +24,16 @@ void FreePhysics( void )
|
|||
Mem_FreePool( &physpool );
|
||||
}
|
||||
|
||||
physic_exp_t DLLEXPORT *CreateAPI ( physic_imp_t *import )
|
||||
physic_exp_t DLLEXPORT *CreateAPI ( stdlib_api_t *input, physic_imp_t *engfuncs )
|
||||
{
|
||||
static physic_exp_t Phys;
|
||||
|
||||
std = *input;
|
||||
|
||||
// Sys_LoadLibrary can create fake instance, to check
|
||||
// api version and api size, but first argument will be 0
|
||||
// api version and api size, but second argument will be 0
|
||||
// and always make exception, run simply check for avoid it
|
||||
if(import) pi = *import;
|
||||
if(engfuncs) pi = *engfuncs;
|
||||
|
||||
// generic functions
|
||||
Phys.api_size = sizeof(physic_exp_t);
|
||||
|
|
|
@ -10,8 +10,10 @@
|
|||
#include <basetypes.h>
|
||||
#include <basemath.h>
|
||||
#include <ref_system.h>
|
||||
#include <ref_stdlib.h>
|
||||
|
||||
extern physic_imp_t pi;
|
||||
extern stdlib_api_t std;
|
||||
extern byte *physpool;
|
||||
extern NewtonWorld *gWorld;
|
||||
long _ftol2( double dblSource );
|
||||
|
@ -22,37 +24,10 @@ void Phys_Frame( float time );
|
|||
void Phys_CreateBOX( sv_edict_t *ed, vec3_t mins, vec3_t maxs, vec3_t org, vec3_t ang, NewtonCollision **newcol, NewtonBody **newbody );
|
||||
void Phys_RemoveBOX( NewtonBody *body );
|
||||
|
||||
/*
|
||||
===========================================
|
||||
memory manager
|
||||
===========================================
|
||||
*/
|
||||
// malloc-free
|
||||
#define Mem_Alloc(pool,size) pi.Stdio.malloc(pool, size, __FILE__, __LINE__)
|
||||
#define Mem_Realloc(pool, ptr, size) pi.Stdio.realloc(pool, ptr, size, __FILE__, __LINE__)
|
||||
#define Mem_Free(mem) pi.Stdio.free(mem, __FILE__, __LINE__)
|
||||
|
||||
// Hunk_AllocName
|
||||
#define Mem_AllocPool(name) pi.Stdio.mallocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) pi.Stdio.freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) pi.Stdio.clearpool(pool, __FILE__, __LINE__)
|
||||
|
||||
#define Mem_Copy(dest, src, size) pi.Stdio.memcpy(dest, src, size, __FILE__, __LINE__)
|
||||
|
||||
/*
|
||||
===========================================
|
||||
System Events
|
||||
===========================================
|
||||
*/
|
||||
#define Msg pi.Stdio.printf
|
||||
#define MsgDev pi.Stdio.dprintf
|
||||
#define MsgWarn pi.Stdio.wprintf
|
||||
#define Sys_LoadLibrary pi.Stdio.LoadLibrary
|
||||
#define Sys_FreeLibrary pi.Stdio.FreeLibrary
|
||||
#define Sys_Sleep pi.Stdio.sleep
|
||||
#define Sys_Print pi.Stdio.print
|
||||
#define Sys_Quit pi.Stdio.exit
|
||||
#define Host_Error pi.Stdio.error
|
||||
#define Msg std.printf
|
||||
#define MsgDev std.dprintf
|
||||
#define MsgWarn std.wprintf
|
||||
#define Host_Error std.error
|
||||
|
||||
typedef struct NewtonUserMeshCollisionCollideDescTag
|
||||
{
|
||||
|
|
|
@ -71,6 +71,7 @@ typedef vec_t vec4_t[4];
|
|||
typedef long fs_offset_t;
|
||||
typedef vec_t matrix3x4[3][4];
|
||||
typedef vec_t matrix4x4[4][4];
|
||||
typedef struct rgbdata_s rgbdata_t;
|
||||
typedef struct physbody_s NewtonBody;
|
||||
typedef struct physworld_s NewtonWorld;
|
||||
typedef struct physjoint_s NewtonJoint;
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// ref_rgbdata.h - imagelib interface
|
||||
//=======================================================================
|
||||
#ifndef REF_RGBDATA_H
|
||||
#define REF_RGBDATA_H
|
||||
|
||||
// opengl mask
|
||||
#define GL_COLOR_INDEX 0x1900
|
||||
#define GL_STENCIL_INDEX 0x1901
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#define GL_RED 0x1903
|
||||
#define GL_GREEN 0x1904
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_ALPHA 0x1906
|
||||
#define GL_RGB 0x1907
|
||||
#define GL_RGBA 0x1908
|
||||
#define GL_LUMINANCE 0x1909
|
||||
#define GL_LUMINANCE_ALPHA 0x190A
|
||||
#define GL_BGR 0x80E0
|
||||
#define GL_BGRA 0x80E1
|
||||
|
||||
// gl data type
|
||||
#define GL_BYTE 0x1400
|
||||
#define GL_UNSIGNED_BYTE 0x1401
|
||||
#define GL_SHORT 0x1402
|
||||
#define GL_UNSIGNED_SHORT 0x1403
|
||||
#define GL_INT 0x1404
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_2_BYTES 0x1407
|
||||
#define GL_3_BYTES 0x1408
|
||||
#define GL_4_BYTES 0x1409
|
||||
#define GL_DOUBLE 0x140A
|
||||
|
||||
// description flags
|
||||
#define IMAGE_CUBEMAP 0x00000001
|
||||
#define IMAGE_HAS_ALPHA 0x00000002
|
||||
#define IMAGE_PREMULT 0x00000004 // indices who need in additional premultiply
|
||||
#define IMAGE_GEN_MIPS 0x00000008 // must generate mips
|
||||
#define IMAGE_CUBEMAP_FLIP 0x00000010 // it's a cubemap with flipped sides( dds pack )
|
||||
|
||||
enum comp_format
|
||||
{
|
||||
PF_UNKNOWN = 0,
|
||||
PF_INDEXED_24, // studio model skins
|
||||
PF_INDEXED_32, // sprite 32-bit palette
|
||||
PF_RGBA_32, // already prepared ".bmp", ".tga" or ".jpg" image
|
||||
PF_ARGB_32, // uncompressed dds image
|
||||
PF_RGB_24, // uncompressed dds or another 24-bit image
|
||||
PF_RGB_24_FLIP, // flip image for screenshots
|
||||
PF_DXT1, // nvidia DXT1 format
|
||||
PF_DXT2, // nvidia DXT2 format
|
||||
PF_DXT3, // nvidia DXT3 format
|
||||
PF_DXT4, // nvidia DXT4 format
|
||||
PF_DXT5, // nvidia DXT5 format
|
||||
PF_ATI1N, // ati 1N texture
|
||||
PF_ATI2N, // ati 2N texture
|
||||
PF_LUMINANCE, // b&w dds image
|
||||
PF_LUMINANCE_16, // b&w hi-res image
|
||||
PF_LUMINANCE_ALPHA, // b&w dds image with alpha channel
|
||||
PF_RXGB, // doom3 normal maps
|
||||
PF_ABGR_64, // uint image
|
||||
PF_RGBA_GN, // internal generated texture
|
||||
PF_TOTALCOUNT, // must be last
|
||||
};
|
||||
|
||||
// format info table
|
||||
typedef struct bpc_desc_s
|
||||
{
|
||||
int format; // pixelformat
|
||||
char name[8]; // used for debug
|
||||
uint glmask; // RGBA mask
|
||||
uint gltype; // open gl datatype
|
||||
int bpp; // channels (e.g. rgb = 3, rgba = 4)
|
||||
int bpc; // sizebytes (byte, short, float)
|
||||
int block; // blocksize < 0 needs alternate calc
|
||||
} bpc_desc_t;
|
||||
|
||||
static const bpc_desc_t PFDesc[] =
|
||||
{
|
||||
{PF_UNKNOWN, "raw", GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 0 },
|
||||
{PF_INDEXED_24, "pal 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 0 },// expand data to RGBA buffer
|
||||
{PF_INDEXED_32, "pal 32", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 0 },
|
||||
{PF_RGBA_32, "RGBA 32",GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
{PF_ARGB_32, "ARGB 32",GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
{PF_RGB_24, "RGB 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, -3 },
|
||||
{PF_RGB_24_FLIP, "RGB 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, -3 },
|
||||
{PF_DXT1, "DXT1", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 8 },
|
||||
{PF_DXT2, "DXT2", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT3, "DXT3", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT4, "DXT4", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT5, "DXT5", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_ATI1N, "ATI1N", GL_RGBA, GL_UNSIGNED_BYTE, 1, 1, 8 },
|
||||
{PF_ATI2N, "3DC", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 16 },
|
||||
{PF_LUMINANCE, "LUM 8", GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, 1, -1 },
|
||||
{PF_LUMINANCE_16, "LUM 16", GL_LUMINANCE, GL_UNSIGNED_BYTE, 2, 2, -2 },
|
||||
{PF_LUMINANCE_ALPHA,"LUM A", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 2, 1, -2 },
|
||||
{PF_RXGB, "RXGB", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 16 },
|
||||
{PF_ABGR_64, "ABGR 64",GL_BGRA, GL_UNSIGNED_BYTE, 4, 2, -8 },
|
||||
{PF_RGBA_GN, "system", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
};
|
||||
|
||||
typedef struct rgbdata_s
|
||||
{
|
||||
word width; // image width
|
||||
word height; // image height
|
||||
byte numLayers; // multi-layer volume
|
||||
byte numMips; // mipmap count
|
||||
byte bitsCount; // RGB bits count
|
||||
uint type; // compression type
|
||||
uint flags; // misc image flags
|
||||
byte *palette; // palette if present
|
||||
byte *buffer; // image buffer
|
||||
uint size; // for bounds checking
|
||||
};
|
||||
|
||||
#endif//REF_RGBDATA_H
|
|
@ -0,0 +1,145 @@
|
|||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// ref_stdlib.h - generic shared interfaces
|
||||
//=======================================================================
|
||||
#ifndef REF_STDLIB_H
|
||||
#define REF_STDLIB_H
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
STDLIB GENERIC ALIAS NAMES
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
==========================================
|
||||
memory manager funcs
|
||||
==========================================
|
||||
*/
|
||||
#define Mem_Alloc(pool, size) std.malloc(pool, size, __FILE__, __LINE__)
|
||||
#define Mem_Realloc(pool, ptr, size) std.realloc(pool, ptr, size, __FILE__, __LINE__)
|
||||
#define Mem_Move(pool, ptr, data, size) std.move(pool, ptr, data, size, __FILE__, __LINE__)
|
||||
#define Mem_Free(mem) std.free(mem, __FILE__, __LINE__)
|
||||
#define Mem_AllocPool(name) std.mallocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) std.freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) std.clearpool(pool, __FILE__, __LINE__)
|
||||
#define Mem_Copy(dest, src, size ) std.memcpy(dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Set(dest, src, size ) std.memset(dest, src, size, __FILE__, __LINE__)
|
||||
#define Mem_Check() std.memcheck(__FILE__, __LINE__)
|
||||
|
||||
/*
|
||||
==========================================
|
||||
parsing manager funcs
|
||||
==========================================
|
||||
*/
|
||||
#define Com_ParseToken std.Com_ParseToken
|
||||
#define Com_ParseWord std.Com_ParseWord
|
||||
#define Com_Filter std.Com_Filter
|
||||
#define Com_LoadScript std.Com_LoadScript
|
||||
#define Com_IncludeScript std.Com_AddScript
|
||||
#define Com_ResetScript std.Com_ResetScript
|
||||
#define Com_GetToken std.Com_ReadToken
|
||||
#define Com_TryToken std.Com_TryToken
|
||||
#define Com_FreeToken std.Com_FreeToken
|
||||
#define Com_SkipToken std.Com_SkipToken
|
||||
#define Com_MatchToken std.Com_MatchToken
|
||||
#define com_token std.com_token
|
||||
#define g_TXcommand std.com_TXcommand // get rid of this
|
||||
|
||||
/*
|
||||
===========================================
|
||||
filesystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define FS_AddGameHierarchy std.Com_AddGameHierarchy
|
||||
#define FS_LoadGameInfo std.Com_LoadGameInfo
|
||||
#define FS_InitRootDir std.Com_InitRootDir
|
||||
#define FS_LoadFile(name, size) std.Com_LoadFile(name, size)
|
||||
#define FS_Search std.Com_Search
|
||||
#define FS_WriteFile(name, data, size) std.Com_WriteFile(name, data, size )
|
||||
#define FS_Open( path, mode ) std.fopen( path, mode )
|
||||
#define FS_Read( file, buffer, size ) std.fread( file, buffer, size )
|
||||
#define FS_Write( file, buffer, size ) std.fwrite( file, buffer, size )
|
||||
#define FS_StripExtension( path ) std.Com_StripExtension( path )
|
||||
#define FS_DefaultExtension( path, ext ) std.Com_DefaultExtension( path, ext )
|
||||
#define FS_FileExtension( ext ) std.Com_FileExtension( ext )
|
||||
#define FS_FileExists( file ) std.Com_FileExists( file )
|
||||
#define FS_Close( file ) std.fclose( file )
|
||||
#define FS_FileBase( x, y ) std.Com_FileBase( x, y )
|
||||
#define FS_Printf std.fprintf
|
||||
#define FS_Print std.fprint
|
||||
#define FS_Seek std.fseek
|
||||
#define FS_Tell std.ftell
|
||||
#define FS_Gets std.fgets
|
||||
#define FS_Gamedir std.GameInfo->gamedir
|
||||
#define FS_Title std.GameInfo->title
|
||||
#define FS_ClearSearchPath std.Com_ClearSearchPath
|
||||
#define FS_CheckParm std.Com_CheckParm
|
||||
#define FS_GetParmFromCmdLine std.Com_GetParm
|
||||
#define FS_LoadImage std.Com_LoadImage
|
||||
#define FS_SaveImage std.Com_SaveImage
|
||||
#define FS_FreeImage std.Com_FreeImage
|
||||
|
||||
/*
|
||||
===========================================
|
||||
virtual filesystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define VFS_Open std.vfopen
|
||||
#define VFS_Write std.vfwrite
|
||||
#define VFS_Write2 std.vfwrite2
|
||||
#define VFS_Read std.vfread
|
||||
#define VFS_Seek std.vfseek
|
||||
#define VFS_Tell std.vftell
|
||||
#define VFS_Close std.vfclose
|
||||
#define VFS_Unpack std.vfunpack
|
||||
|
||||
/*
|
||||
===========================================
|
||||
crclib manager
|
||||
===========================================
|
||||
*/
|
||||
#define CRC_Init std.crc_init
|
||||
#define CRC_Block std.crc_block
|
||||
#define CRC_ProcessByte std.crc_process
|
||||
#define CRC_Sequence std.crc_sequence
|
||||
|
||||
/*
|
||||
===========================================
|
||||
imagelib utils
|
||||
===========================================
|
||||
*/
|
||||
#define Image_Processing std.Com_ProcessImage
|
||||
|
||||
/*
|
||||
===========================================
|
||||
misc utils
|
||||
===========================================
|
||||
*/
|
||||
#define GI std.GameInfo
|
||||
#define Sys_LoadLibrary std.Com_LoadLibrary
|
||||
#define Sys_FreeLibrary std.Com_FreeLibrary
|
||||
#define Sys_GetProcAddress std.Com_GetProcAddress
|
||||
#define Sys_Sleep std.sleep
|
||||
#define Sys_Print std.print
|
||||
#define Sys_ConsoleInput std.input
|
||||
#define Sys_GetKeyEvents std.keyevents
|
||||
#define Sys_GetClipboardData std.clipboard
|
||||
#define Sys_Quit std.exit
|
||||
#define Sys_ConsoleInput std.input
|
||||
#define GetNumThreads std.Com_NumThreads
|
||||
#define ThreadLock std.Com_ThreadLock
|
||||
#define ThreadUnlock std.Com_ThreadUnlock
|
||||
#define RunThreadsOnIndividual std.Com_CreateThread
|
||||
|
||||
/*
|
||||
===========================================
|
||||
misc utils
|
||||
===========================================
|
||||
*/
|
||||
#define timestamp std.timestamp
|
||||
#define copystring std.stralloc
|
||||
#define va std.va
|
||||
|
||||
#endif//REF_STDLIB_H
|
|
@ -14,19 +14,6 @@
|
|||
#define TIME_TIME_ONLY 2
|
||||
#define TIME_NO_SECONDS 3
|
||||
|
||||
// bsplib compile flags
|
||||
#define BSP_ONLYENTS 0x01
|
||||
#define BSP_ONLYVIS 0x02
|
||||
#define BSP_ONLYRAD 0x04
|
||||
#define BSP_FULLCOMPILE 0x08
|
||||
|
||||
// qcclib compile flags
|
||||
#define QCC_PROGDEFS 0x01
|
||||
#define QCC_OPT_LEVEL_0 0x02
|
||||
#define QCC_OPT_LEVEL_1 0x04
|
||||
#define QCC_OPT_LEVEL_2 0x08
|
||||
#define QCC_OPT_LEVEL_3 0x10
|
||||
|
||||
#define MAX_DLIGHTS 32
|
||||
#define MAX_ENTITIES 128
|
||||
#define MAX_PARTICLES 4096
|
||||
|
@ -87,57 +74,20 @@
|
|||
#define MOVETYPE_CONVEYOR 9
|
||||
#define MOVETYPE_PUSHABLE 10
|
||||
|
||||
// opengl mask
|
||||
#define GL_COLOR_INDEX 0x1900
|
||||
#define GL_STENCIL_INDEX 0x1901
|
||||
#define GL_DEPTH_COMPONENT 0x1902
|
||||
#define GL_RED 0x1903
|
||||
#define GL_GREEN 0x1904
|
||||
#define GL_BLUE 0x1905
|
||||
#define GL_ALPHA 0x1906
|
||||
#define GL_RGB 0x1907
|
||||
#define GL_RGBA 0x1908
|
||||
#define GL_LUMINANCE 0x1909
|
||||
#define GL_LUMINANCE_ALPHA 0x190A
|
||||
#define GL_BGR 0x80E0
|
||||
#define GL_BGRA 0x80E1
|
||||
|
||||
// gl data type
|
||||
#define GL_BYTE 0x1400
|
||||
#define GL_UNSIGNED_BYTE 0x1401
|
||||
#define GL_SHORT 0x1402
|
||||
#define GL_UNSIGNED_SHORT 0x1403
|
||||
#define GL_INT 0x1404
|
||||
#define GL_UNSIGNED_INT 0x1405
|
||||
#define GL_FLOAT 0x1406
|
||||
#define GL_2_BYTES 0x1407
|
||||
#define GL_3_BYTES 0x1408
|
||||
#define GL_4_BYTES 0x1409
|
||||
#define GL_DOUBLE 0x140A
|
||||
|
||||
enum comp_format
|
||||
enum
|
||||
{
|
||||
PF_UNKNOWN = 0,
|
||||
PF_INDEXED_24, // studio model skins
|
||||
PF_INDEXED_32, // sprite 32-bit palette
|
||||
PF_RGBA_32, // already prepared ".bmp", ".tga" or ".jpg" image
|
||||
PF_ARGB_32, // uncompressed dds image
|
||||
PF_RGB_24, // uncompressed dds or another 24-bit image
|
||||
PF_RGB_24_FLIP, // flip image for screenshots
|
||||
PF_DXT1, // nvidia DXT1 format
|
||||
PF_DXT2, // nvidia DXT2 format
|
||||
PF_DXT3, // nvidia DXT3 format
|
||||
PF_DXT4, // nvidia DXT4 format
|
||||
PF_DXT5, // nvidia DXT5 format
|
||||
PF_ATI1N, // ati 1N texture
|
||||
PF_ATI2N, // ati 2N texture
|
||||
PF_LUMINANCE, // b&w dds image
|
||||
PF_LUMINANCE_16, // b&w hi-res image
|
||||
PF_LUMINANCE_ALPHA, // b&w dds image with alpha channel
|
||||
PF_RXGB, // doom3 normal maps
|
||||
PF_ABGR_64, // uint image
|
||||
PF_RGBA_GN, // internal generated texture
|
||||
PF_TOTALCOUNT, // must be last
|
||||
HOST_OFFLINE = 0, // host_init( funcname *arg ) same much as:
|
||||
HOST_NORMAL, // "host_shared"
|
||||
HOST_DEDICATED, // "host_dedicated"
|
||||
HOST_EDITOR, // "host_editor"
|
||||
BSPLIB, // "bsplib"
|
||||
IMGLIB, // "imglib"
|
||||
QCCLIB, // "qcclib"
|
||||
ROQLIB, // "roqlib"
|
||||
SPRITE, // "sprite"
|
||||
STUDIO, // "studio"
|
||||
CREDITS, // "splash"
|
||||
HOST_INSTALL, // "install"
|
||||
};
|
||||
|
||||
enum ai_activity
|
||||
|
@ -268,42 +218,6 @@ enum dev_level
|
|||
D_NOTE, // "-dev 5", show system notifications for engine develeopers
|
||||
};
|
||||
|
||||
// format info table
|
||||
typedef struct
|
||||
{
|
||||
int format; // pixelformat
|
||||
char name[8]; // used for debug
|
||||
uint glmask; // RGBA mask
|
||||
uint gltype; // open gl datatype
|
||||
int bpp; // channels (e.g. rgb = 3, rgba = 4)
|
||||
int bpc; // sizebytes (byte, short, float)
|
||||
int block; // blocksize < 0 needs alternate calc
|
||||
} bpc_desc_t;
|
||||
|
||||
static bpc_desc_t PFDesc[] =
|
||||
{
|
||||
{PF_UNKNOWN, "raw", GL_RGBA, GL_UNSIGNED_BYTE, 0, 0, 0 },
|
||||
{PF_INDEXED_24, "pal 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 0 },// expand data to RGBA buffer
|
||||
{PF_INDEXED_32, "pal 32", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 0 },
|
||||
{PF_RGBA_32, "RGBA 32",GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
{PF_ARGB_32, "ARGB 32",GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
{PF_RGB_24, "RGB 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, -3 },
|
||||
{PF_RGB_24_FLIP, "RGB 24", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, -3 },
|
||||
{PF_DXT1, "DXT1", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 8 },
|
||||
{PF_DXT2, "DXT2", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT3, "DXT3", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT4, "DXT4", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_DXT5, "DXT5", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, 16 },
|
||||
{PF_ATI1N, "ATI1N", GL_RGBA, GL_UNSIGNED_BYTE, 1, 1, 8 },
|
||||
{PF_ATI2N, "3DC", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 16 },
|
||||
{PF_LUMINANCE, "LUM 8", GL_LUMINANCE, GL_UNSIGNED_BYTE, 1, 1, -1 },
|
||||
{PF_LUMINANCE_16, "LUM 16", GL_LUMINANCE, GL_UNSIGNED_BYTE, 2, 2, -2 },
|
||||
{PF_LUMINANCE_ALPHA,"LUM A", GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, 2, 1, -2 },
|
||||
{PF_RXGB, "RXGB", GL_RGBA, GL_UNSIGNED_BYTE, 3, 1, 16 },
|
||||
{PF_ABGR_64, "ABGR 64",GL_BGRA, GL_UNSIGNED_BYTE, 4, 2, -8 },
|
||||
{PF_RGBA_GN, "system", GL_RGBA, GL_UNSIGNED_BYTE, 4, 1, -4 },
|
||||
};
|
||||
|
||||
static activity_map_t activity_map[] =
|
||||
{
|
||||
{ACT_IDLE, "ACT_IDLE" },
|
||||
|
@ -411,19 +325,6 @@ static activity_map_t activity_map[] =
|
|||
{0, NULL },
|
||||
};
|
||||
|
||||
#define IMAGE_CUBEMAP 0x00000001
|
||||
#define IMAGE_HAS_ALPHA 0x00000002
|
||||
#define IMAGE_PREMULT 0x00000004 // indices who need in additional premultiply
|
||||
#define IMAGE_GEN_MIPS 0x00000008 // must generate mips
|
||||
#define IMAGE_CUBEMAP_FLIP 0x00000010 // it's a cubemap with flipped sides( dds pack )
|
||||
|
||||
#define CUBEMAP_POSITIVEX 0x00000400L
|
||||
#define CUBEMAP_NEGATIVEX 0x00000800L
|
||||
#define CUBEMAP_POSITIVEY 0x00001000L
|
||||
#define CUBEMAP_NEGATIVEY 0x00002000L
|
||||
#define CUBEMAP_POSITIVEZ 0x00004000L
|
||||
#define CUBEMAP_NEGATIVEZ 0x00008000L
|
||||
|
||||
typedef struct search_s
|
||||
{
|
||||
int numfilenames;
|
||||
|
@ -432,20 +333,6 @@ typedef struct search_s
|
|||
|
||||
} search_t;
|
||||
|
||||
typedef struct rgbdata_s
|
||||
{
|
||||
word width; // image width
|
||||
word height; // image height
|
||||
byte numLayers; // multi-layer volume
|
||||
byte numMips; // mipmap count
|
||||
byte bitsCount; // RGB bits count
|
||||
uint type; // compression type
|
||||
uint flags; // misc image flags
|
||||
byte *palette; // palette if present
|
||||
byte *buffer; // image buffer
|
||||
uint size; // for bounds checking
|
||||
} rgbdata_t;
|
||||
|
||||
typedef struct physdata_s
|
||||
{
|
||||
vec3_t origin;
|
||||
|
@ -489,7 +376,7 @@ typedef struct dll_info_s
|
|||
void *link; // hinstance of loading library
|
||||
|
||||
// xash dlls entrypoint
|
||||
void *(*main)( void* ); // point type (e.g. common_t)
|
||||
void *(*main)( void*, void* );
|
||||
bool crash; // crash if dll not found
|
||||
|
||||
// xash dlls validator
|
||||
|
@ -725,136 +612,7 @@ typedef struct generic_api_s
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
FILESYSTEM ENGINE INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct filesystem_api_s
|
||||
{
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(filesystem_api_t)
|
||||
|
||||
// base functions
|
||||
void (*FileBase)(char *in, char *out); // get filename without path & ext
|
||||
bool (*FileExists)(const char *filename); // return true if file exist
|
||||
long (*FileSize)(const char *filename); // same as FileExists but return filesize
|
||||
const char *(*FileExtension)(const char *in); // return extension of file
|
||||
const char *(*FileWithoutPath)(const char *in); // return file without path
|
||||
void (*StripExtension)(char *path); // remove extension if present
|
||||
void (*StripFilePath)(const char* const src, char* dst); // get file path without filename.ext
|
||||
void (*DefaultExtension)(char *path, const char *ext ); // append extension if not present
|
||||
void (*ClearSearchPath)( void ); // delete all search pathes
|
||||
|
||||
// built-in search interface
|
||||
search_t *(*Search)(const char *pattern, int casecmp ); // returned list of found files
|
||||
|
||||
// file low-level operations
|
||||
file_t *(*Open)(const char* path, const char* mode); // same as fopen
|
||||
int (*Close)(file_t* file); // same as fclose
|
||||
long (*Write)(file_t* file, const void* data, size_t datasize); // same as fwrite
|
||||
long (*Read)(file_t* file, void* buffer, size_t buffersize); // same as fread, can see trough pakfile
|
||||
int (*Print)(file_t* file, const char *msg); // printed message into file
|
||||
int (*Printf)(file_t* file, const char* format, ...); // same as fprintf
|
||||
int (*Gets)(file_t* file, byte *string, size_t bufsize ); // like a fgets, but can return EOF
|
||||
int (*Seek)(file_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
||||
long (*Tell)(file_t* file); // like a ftell
|
||||
|
||||
// fs simply user interface
|
||||
byte *(*LoadFile)(const char *path, long *filesize ); // load file into heap
|
||||
bool (*WriteFile)(const char *filename, void *data, long len); // write file into disk
|
||||
|
||||
} filesystem_api_t;
|
||||
|
||||
typedef struct vfilesystem_api_s
|
||||
{
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(vfilesystem_api_t)
|
||||
|
||||
// file low-level operations
|
||||
vfile_t *(*Create)(byte *buffer, size_t buffsize); // create virtual stream
|
||||
vfile_t *(*Open)(const char *filename, const char* mode); // virtual fopen
|
||||
int (*Close)(vfile_t* file); // free buffer or write dump
|
||||
long (*Write)(vfile_t* file, const void* data, size_t datasize); // write into buffer
|
||||
long (*Read)(vfile_t* file, void* buffer, size_t buffersize); // read from buffer
|
||||
int (*Seek)(vfile_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
||||
long (*Tell)(vfile_t* file); // like a ftell
|
||||
|
||||
} vfilesystem_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
INFOSTRING MANAGER ENGINE INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct infostring_api_s
|
||||
{
|
||||
//interface validator
|
||||
size_t api_size; // must matched with sizeof(infostring_api_t)
|
||||
|
||||
void (*Print) (char *s);
|
||||
bool (*Validate) (char *s);
|
||||
void (*RemoveKey) (char *s, char *key);
|
||||
char *(*ValueForKey) (char *s, char *key);
|
||||
void (*SetValueForKey) (char *s, char *key, char *value);
|
||||
|
||||
} infostring_api_t;
|
||||
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
PARSE STUFF SYSTEM INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct scriptsystem_api_s
|
||||
{
|
||||
//interface validator
|
||||
size_t api_size; // must matched with sizeof(scriptsystem_api_t)
|
||||
|
||||
//user interface
|
||||
bool (*Load)( const char *name, char *buf, int size );// load script into stack from file or bufer
|
||||
bool (*Include)( const char *name, char *buf, int size ); // include script from file or buffer
|
||||
void (*Reset)( void ); // reset current script state
|
||||
char *(*GetToken)( bool newline ); // get next token on a line or newline
|
||||
bool (*TryToken)( void ); // return 1 if have token on a line
|
||||
void (*FreeToken)( void ); // free current token to may get it again
|
||||
void (*SkipToken)( void ); // skip current token and jump into newline
|
||||
bool (*MatchToken)( const char *match ); // compare current token with user keyword
|
||||
char *(*ParseToken)(const char **data ); // parse token from char buffer
|
||||
char *(*ParseWord)( const char **data ); // parse word from char buffer
|
||||
bool (*FilterToken)(char *filter, char *name, int casecmp); // compare keyword by mask with filter
|
||||
char *Token; // contains current token
|
||||
char g_TXcommand; // quark command
|
||||
|
||||
} scriptsystem_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
INTERNAL COMPILERS INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct compilers_api_s
|
||||
{
|
||||
//interface validator
|
||||
size_t api_size; // must matched with sizeof(compilers_api_t)
|
||||
|
||||
bool (*Studio)( byte *mempool, const char *name, byte parms ); // input name of qc-script
|
||||
bool (*Sprite)( byte *mempool, const char *name, byte parms ); // input name of qc-script
|
||||
bool (*Image)( byte *mempool, const char *name, byte parms ); // input name of image
|
||||
bool (*PrepareBSP)( const char *dir, const char *name, byte params ); // compile map in gamedir
|
||||
bool (*BSP)( void );
|
||||
bool (*PrepareDAT)( const char *dir, const char *name, byte params ); // compile dat in gamedir
|
||||
bool (*DAT)( void );
|
||||
bool (*DecryptDAT)( int complen, int len, int method, char *info, char **buffer); //unpacking dat
|
||||
bool (*PrepareROQ)( const char *dir, const char *name, byte params ); // compile roq in gamedir
|
||||
bool (*ROQ)( void );
|
||||
} compilers_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
STDIO SYSTEM INTERFACE
|
||||
STDLIB SYSTEM INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct stdilib_api_s
|
||||
|
@ -872,10 +630,7 @@ typedef struct stdilib_api_s
|
|||
char *(*input)( void ); // system console input
|
||||
void (*sleep)( int msec ); // sleep for some msec
|
||||
char *(*clipboard)( void ); // get clipboard data
|
||||
void (*create_thread)(int, bool, void(*fn)(int)); // run individual thread
|
||||
void (*thread_lock)( void );
|
||||
void (*thread_unlock)( void );
|
||||
int (*get_numthreads)( void );
|
||||
uint (*keyevents)( void ); // peek windows message
|
||||
|
||||
// crclib.c funcs
|
||||
void (*crc_init)(word *crcvalue); // set initial crc value
|
||||
|
@ -897,20 +652,72 @@ typedef struct stdilib_api_s
|
|||
void (*clearpool)(byte *poolptr, const char *file, int line);
|
||||
void (*memcheck)(const char *file, int line); // check memory pools for consistensy
|
||||
|
||||
// path initialization
|
||||
void (*InitRootDir)( char *path ); // init custom rootdir
|
||||
void (*LoadGameInfo)( const char *filename ); // gate game info from script file
|
||||
void (*AddGameHierarchy)(const char *dir); // add base directory in search list
|
||||
// common functions
|
||||
void (*Com_InitRootDir)( char *path ); // init custom rootdir
|
||||
void (*Com_LoadGameInfo)( const char *filename ); // gate game info from script file
|
||||
void (*Com_AddGameHierarchy)(const char *dir); // add base directory in search list
|
||||
int (*Com_CheckParm)( const char *parm ); // check parm in cmdline
|
||||
bool (*Com_GetParm)( char *parm, char *out ); // get parm from cmdline
|
||||
void (*Com_FileBase)(char *in, char *out); // get filename without path & ext
|
||||
bool (*Com_FileExists)(const char *filename); // return true if file exist
|
||||
long (*Com_FileSize)(const char *filename); // same as Com_FileExists but return filesize
|
||||
const char *(*Com_FileExtension)(const char *in); // return extension of file
|
||||
const char *(*Com_RemovePath)(const char *in); // return file without path
|
||||
void (*Com_StripExtension)(char *path); // remove extension if present
|
||||
void (*Com_StripFilePath)(const char* const src, char* dst);// get file path without filename.ext
|
||||
void (*Com_DefaultExtension)(char *path, const char *ext ); // append extension if not present
|
||||
void (*Com_ClearSearchPath)( void ); // delete all search pathes
|
||||
void (*Com_CreateThread)(int, bool, void(*fn)(int)); // run individual thread
|
||||
void (*Com_ThreadLock)( void ); // lock current thread
|
||||
void (*Com_ThreadUnlock)( void ); // unlock numthreads
|
||||
int (*Com_NumThreads)( void ); // returns count of active threads
|
||||
bool (*Com_LoadScript)(const char *name,char *buf,int size);// load script into stack from file or bufer
|
||||
bool (*Com_AddScript)(const char *name,char *buf, int size);// include script from file or buffer
|
||||
void (*Com_ResetScript)( void ); // reset current script state
|
||||
char *(*Com_ReadToken)( bool newline ); // get next token on a line or newline
|
||||
bool (*Com_TryToken)( void ); // return 1 if have token on a line
|
||||
void (*Com_FreeToken)( void ); // free current token to may get it again
|
||||
void (*Com_SkipToken)( void ); // skip current token and jump into newline
|
||||
bool (*Com_MatchToken)( const char *match ); // compare current token with user keyword
|
||||
char *(*Com_ParseToken)(const char **data ); // parse token from char buffer
|
||||
char *(*Com_ParseWord)( const char **data ); // parse word from char buffer
|
||||
search_t *(*Com_Search)(const char *pattern, int casecmp ); // returned list of found files
|
||||
bool (*Com_Filter)(char *filter, char *name, int casecmp ); // compare keyword by mask with filter
|
||||
char *com_token; // contains current token
|
||||
|
||||
filesystem_api_t Fs; // filesystem
|
||||
vfilesystem_api_t VFs; // virtual filesystem
|
||||
// real filesystem
|
||||
file_t *(*fopen)(const char* path, const char* mode); // same as fopen
|
||||
int (*fclose)(file_t* file); // same as fclose
|
||||
long (*fwrite)(file_t* file, const void* data, size_t datasize); // same as fwrite
|
||||
long (*fread)(file_t* file, void* buffer, size_t buffersize); // same as fread, can see trough pakfile
|
||||
int (*fprint)(file_t* file, const char *msg); // printed message into file
|
||||
int (*fprintf)(file_t* file, const char* format, ...); // same as fprintf
|
||||
int (*fgets)(file_t* file, byte *string, size_t bufsize ); // like a fgets, but can return EOF
|
||||
int (*fseek)(file_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
||||
long (*ftell)(file_t* file); // like a ftell
|
||||
|
||||
// timelib.c funcs
|
||||
const char* (*time_stamp)( int format ); // returns current time stamp
|
||||
double (*gettime)( void ); // hi-res timer
|
||||
gameinfo_t *GameInfo; // misc utils
|
||||
// virtual filesystem
|
||||
vfile_t *(*vfcreate)(byte *buffer, size_t buffsize); // create virtual stream
|
||||
vfile_t *(*vfopen)(const char *filename, const char* mode); // virtual fopen
|
||||
int (*vfclose)(vfile_t* file); // free buffer or write dump
|
||||
long (*vfwrite)(vfile_t* file, const void* buf, size_t datasize); // write into buffer
|
||||
long (*vfwrite2)(vfile_t* handle, byte* buffer, size_t datasize); // deflate and write into buffer
|
||||
long (*vfread)(vfile_t* file, void* buffer, size_t buffersize); // read from buffer
|
||||
int (*vfseek)(vfile_t* file, fs_offset_t offset, int whence); // fseek, can seek in packfiles too
|
||||
bool (*vfunpack)( void* comp, size_t size1, void **buf, size_t size2);// deflate zipped buffer
|
||||
long (*vftell)(vfile_t* file); // like a ftell
|
||||
|
||||
scriptsystem_api_t Script; // parselib.c
|
||||
// filesystem simply user interface
|
||||
byte *(*Com_LoadFile)(const char *path, long *filesize ); // load file into heap
|
||||
bool (*Com_WriteFile)(const char *path, void *data, long len); // write file into disk
|
||||
rgbdata_t *(*Com_LoadImage)(const char *path, char *data, int size ); // extract image into rgba buffer
|
||||
void (*Com_SaveImage)(const char *filename, rgbdata_t *buffer ); // save image into specified format
|
||||
bool (*Com_ProcessImage)( const char *name, rgbdata_t **pix ); // convert and resample image
|
||||
void (*Com_FreeImage)( rgbdata_t *pack ); // free image buffer
|
||||
bool (*Com_LoadLibrary)( dll_info_t *dll ); // load library
|
||||
bool (*Com_FreeLibrary)( dll_info_t *dll ); // free library
|
||||
void*(*Com_GetProcAddress)( dll_info_t *dll, const char* name ); // gpa
|
||||
double (*Com_DoubleTime)( void ); // hi-res timer
|
||||
|
||||
// stdlib.c funcs
|
||||
void (*strnupr)(const char *in, char *out, size_t size_out);// convert string to upper case
|
||||
|
@ -944,34 +751,17 @@ typedef struct stdilib_api_s
|
|||
char *(*va)(const char *format, ...); // print into temp buffer
|
||||
int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list args); // format message
|
||||
int (*snprintf)(char *buffer, size_t buffersize, const char *format, ...); // print into buffer
|
||||
const char* (*timestamp)( int format ); // returns current time stamp
|
||||
|
||||
// xash dll loading system
|
||||
bool (*LoadLibrary)( dll_info_t *dll ); // load library
|
||||
bool (*FreeLibrary)( dll_info_t *dll ); // free library
|
||||
void*(*GetProcAddress)( dll_info_t *dll, const char* name ); // gpa
|
||||
// misc utils
|
||||
gameinfo_t *GameInfo; // user game info (filled by engine)
|
||||
char com_TXcommand; // quark command (get rid of this)
|
||||
|
||||
} stdlib_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
CVAR SYSTEM INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
typedef struct cvar_api_s
|
||||
{
|
||||
//interface validator
|
||||
size_t api_size; // must matched with sizeof(cvar_api_t)
|
||||
|
||||
//cvar_t *(*Register)(const char *name, const char *value, int flags, const char *description );
|
||||
//cvar_t *(*SetString)(const char *name, char *value);
|
||||
//void (*SetValue)(const char *name, float value);
|
||||
|
||||
} cvar_api_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
LAUNCH.DLL INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
|
@ -980,7 +770,7 @@ typedef struct launch_exp_s
|
|||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(launch_api_t)
|
||||
|
||||
void ( *Init ) ( char *funcname, int argc, char **argv ); // init host
|
||||
void ( *Init ) ( uint funcname, int argc, char **argv ); // init host
|
||||
void ( *Main ) ( void ); // host frame
|
||||
void ( *Free ) ( void ); // close host
|
||||
|
||||
|
@ -989,32 +779,6 @@ typedef struct launch_exp_s
|
|||
/*
|
||||
==============================================================================
|
||||
|
||||
COMMON.DLL INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
|
||||
typedef struct common_exp_s
|
||||
{
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(common_api_t)
|
||||
|
||||
// initialize
|
||||
bool (*Init)( int argc, char **argv ); // init all common systems
|
||||
void (*Shutdown)( void ); // shutdown all common systems
|
||||
|
||||
rgbdata_t *(*LoadImage)(const char *filename, char *data, int size );
|
||||
void (*SaveImage)(const char *filename, rgbdata_t *buffer );
|
||||
void (*FreeImage)( rgbdata_t *pack );
|
||||
|
||||
// common systems
|
||||
compilers_api_t Compile;
|
||||
infostring_api_t Info;
|
||||
|
||||
} common_exp_t;
|
||||
|
||||
/*
|
||||
==============================================================================
|
||||
|
||||
RENDER.DLL INTERFACE
|
||||
==============================================================================
|
||||
*/
|
||||
|
@ -1057,17 +821,13 @@ typedef struct render_exp_s
|
|||
void (*CinematicSetPalette)( const byte *palette); // NULL = game palette
|
||||
void (*BeginFrame)( void );
|
||||
void (*EndFrame)( void );
|
||||
|
||||
} render_exp_t;
|
||||
|
||||
typedef struct render_imp_s
|
||||
{
|
||||
// shared xash systems
|
||||
compilers_api_t Compile;
|
||||
stdlib_api_t Stdio;
|
||||
|
||||
rgbdata_t *(*LoadImage)(const char *filename, char *data, int size );
|
||||
void (*SaveImage)(const char *filename, rgbdata_t *buffer );
|
||||
void (*FreeImage)( rgbdata_t *pack );
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(render_imp_t)
|
||||
|
||||
void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
|
||||
void (*Cmd_RemoveCommand) (char *name);
|
||||
|
@ -1079,11 +839,6 @@ typedef struct render_imp_s
|
|||
void (*StudioEvent)( mstudioevent_t *event, entity_t *ent );
|
||||
void (*ShowCollision)( void );// debug
|
||||
|
||||
// gamedir will be the current directory that generated
|
||||
// files should be stored to, ie: "f:\quake\id1"
|
||||
char *(*gamedir) ( void );
|
||||
char *(*title) ( void );
|
||||
|
||||
cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
|
||||
void (*Cvar_Set)( char *name, char *value );
|
||||
void (*Cvar_SetValue)( char *name, float value );
|
||||
|
@ -1117,22 +872,19 @@ typedef struct physic_exp_s
|
|||
// simple objects
|
||||
void (*CreateBOX)( sv_edict_t *ed, vec3_t mins, vec3_t maxs, vec3_t org, vec3_t ang, NewtonCollision **newcol, NewtonBody **newbody );
|
||||
void (*RemoveBOX)( NewtonBody *body );
|
||||
|
||||
} physic_exp_t;
|
||||
|
||||
typedef struct physic_imp_s
|
||||
{
|
||||
// shared xash systems
|
||||
compilers_api_t Compile;
|
||||
stdlib_api_t Stdio;
|
||||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(physic_imp_t)
|
||||
|
||||
void (*Transform)( sv_edict_t *ed, vec3_t origin, vec3_t angles );
|
||||
|
||||
} physic_imp_t;
|
||||
|
||||
// this is the only function actually exported at the linker level
|
||||
typedef render_exp_t *(*render_t)( render_imp_t* );
|
||||
typedef physic_exp_t *(*physic_t)( physic_imp_t* );
|
||||
typedef common_exp_t *(*common_t)( stdlib_api_t* );
|
||||
typedef launch_exp_t *(*launch_t)( stdlib_api_t* );
|
||||
typedef void *(*launch_t)( stdlib_api_t*, void* );
|
||||
|
||||
#endif//REF_SYSTEM_H
|
|
@ -23,6 +23,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "basetypes.h"
|
||||
#include <basemath.h>
|
||||
#include "ref_system.h"
|
||||
#include "ref_stdlib.h"
|
||||
#include "ref_rgbdata.h"
|
||||
#include "materials.h"
|
||||
|
||||
#define RENDERPASS_SOLID 1
|
||||
|
@ -46,59 +48,23 @@ memory manager
|
|||
#define Z_Malloc(size) Mem_Alloc(r_temppool, size)
|
||||
#define Z_Free(data) Mem_Free(data)
|
||||
|
||||
//malloc-free
|
||||
#define Mem_Alloc(pool,size) ri.Stdio.malloc(pool, size, __FILE__, __LINE__)
|
||||
#define Mem_Free(mem) ri.Stdio.free(mem, __FILE__, __LINE__)
|
||||
#define Mem_Copy(dst, src, size) ri.Stdio.memcpy(dst, src, size, __FILE__, __LINE__)
|
||||
|
||||
//Hunk_AllocName
|
||||
#define Mem_AllocPool(name) ri.Stdio.mallocpool(name, __FILE__, __LINE__)
|
||||
#define Mem_FreePool(pool) ri.Stdio.freepool(pool, __FILE__, __LINE__)
|
||||
#define Mem_EmptyPool(pool) ri.Stdio.clearpool(pool, __FILE__, __LINE__)
|
||||
|
||||
extern byte *r_temppool;
|
||||
extern stdlib_api_t std;
|
||||
|
||||
//r_utils.c
|
||||
// r_utils.c
|
||||
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees );
|
||||
void ProjectPointOnPlane( vec3_t dst, const vec3_t p, const vec3_t normal );
|
||||
void PerpendicularVector( vec3_t dst, const vec3_t src );
|
||||
void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
|
||||
void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
||||
|
||||
#define Msg ri.Stdio.printf
|
||||
#define MsgDev ri.Stdio.dprintf
|
||||
#define MsgWarn ri.Stdio.wprintf
|
||||
#define Sys_Error ri.Stdio.error
|
||||
#define Msg std.printf
|
||||
#define MsgDev std.dprintf
|
||||
#define MsgWarn std.wprintf
|
||||
#define Sys_Error std.error
|
||||
|
||||
#define strcasecmp ri.Stdio.stricmp
|
||||
#define va ri.Stdio.va
|
||||
|
||||
/*
|
||||
===========================================
|
||||
filesystem manager
|
||||
===========================================
|
||||
*/
|
||||
#define FS_LoadFile(name, size) ri.Stdio.Fs.LoadFile(name, size)
|
||||
#define FS_LoadImage(name, data, size) ri.LoadImage(name, data, size)
|
||||
#define FS_SaveImage(name, pic) ri.SaveImage(name, pic)
|
||||
#define FS_FreeImage(data) ri.FreeImage(data)
|
||||
#define FS_Search(path) ri.Stdio.Fs.Search( path, true )
|
||||
#define FS_WriteFile(name, data, size) ri.Stdio.Fs.WriteFile(name, data, size )
|
||||
#define FS_Open( path, mode ) ri.Stdio.Fs.Open( path, mode )
|
||||
#define FS_Read( file, buffer, size ) ri.Stdio.Fs.Read( file, buffer, size )
|
||||
#define FS_Write( file, buffer, size ) ri.Stdio.Fs.Write( file, buffer, size )
|
||||
#define FS_StripExtension( path ) ri.Stdio.Fs.StripExtension( path )
|
||||
#define FS_DefaultExtension( path, ext ) ri.Stdio.Fs.DefaultExtension( path, ext )
|
||||
#define FS_FileExtension( ext ) ri.Stdio.Fs.FileExtension( ext )
|
||||
#define FS_FileExists( file ) ri.Stdio.Fs.FileExists( file )
|
||||
#define FS_Close( file ) ri.Stdio.Fs.Close( file )
|
||||
#define FS_FileBase( x, y ) ri.Stdio.Fs.FileBase( x, y )
|
||||
#define FS_Printf ri.Stdio.Fs.Printf
|
||||
#define FS_Seek ri.Stdio.Fs.Seek
|
||||
#define FS_Tell ri.Stdio.Fs.Tell
|
||||
#define FS_Gets ri.Stdio.Fs.Gets
|
||||
char *FS_Gamedir( void );
|
||||
char *FS_Title( void );
|
||||
#define strcasecmp std.stricmp
|
||||
#define va std.va
|
||||
|
||||
// up / down
|
||||
#define PITCH 0
|
||||
|
|
|
@ -25,6 +25,7 @@ void R_Clear (void);
|
|||
viddef_t vid;
|
||||
|
||||
render_imp_t ri;
|
||||
stdlib_api_t std;
|
||||
|
||||
byte *r_temppool;
|
||||
|
||||
|
@ -716,6 +717,9 @@ void R_DrawPauseScreen( void )
|
|||
if(r_newrefdef.rdflags & RDF_NOWORLDMODEL)
|
||||
return;
|
||||
|
||||
// temporary disabled
|
||||
return;
|
||||
|
||||
if(r_pause->modified )
|
||||
{
|
||||
// reset saturation value
|
||||
|
@ -1521,14 +1525,15 @@ CreateAPI
|
|||
|
||||
@@@@@@@@@@@@@@@@@@@@@
|
||||
*/
|
||||
render_exp_t DLLEXPORT *CreateAPI(render_imp_t *rimp )
|
||||
render_exp_t DLLEXPORT *CreateAPI(stdlib_api_t *input, render_imp_t *engfuncs )
|
||||
{
|
||||
static render_exp_t re;
|
||||
|
||||
std = *input;
|
||||
// Sys_LoadLibrary can create fake instance, to check
|
||||
// api version and api size, but first argument will be 0
|
||||
// api version and api size, but second argument will be 0
|
||||
// and always make exception, run simply check for avoid it
|
||||
if(rimp) ri = *rimp;
|
||||
if(engfuncs) ri = *engfuncs;
|
||||
|
||||
// generic functions
|
||||
re.api_size = sizeof(render_exp_t);
|
||||
|
@ -1565,14 +1570,4 @@ render_exp_t DLLEXPORT *CreateAPI(render_imp_t *rimp )
|
|||
re.AppActivate = GLimp_AppActivate;
|
||||
|
||||
return &re;
|
||||
}
|
||||
|
||||
char *FS_Gamedir( void )
|
||||
{
|
||||
return ri.gamedir();
|
||||
}
|
||||
|
||||
char *FS_Title( void )
|
||||
{
|
||||
return ri.title();
|
||||
}
|
|
@ -3439,7 +3439,7 @@ void GLimp_EnableLogging( bool enable )
|
|||
|
||||
asctime( newtime );
|
||||
|
||||
sprintf( buffer, "%s/gl.log", FS_Gamedir() );
|
||||
sprintf( buffer, "%s/gl.log", FS_Gamedir );
|
||||
glw_state.log_fp = fopen( buffer, "wt" );
|
||||
|
||||
fprintf( glw_state.log_fp, "%s\n", asctime( newtime ) );
|
||||
|
|
|
@ -71,7 +71,7 @@ bool VID_CreateWindow( int width, int height, bool fullscreen )
|
|||
int x, y, w, h;
|
||||
int exstyle;
|
||||
|
||||
strcpy(wndname, FS_Title());//critical stuff.
|
||||
strcpy(wndname, FS_Title ); //critical stuff.
|
||||
|
||||
// Register the frame class
|
||||
wc.style = 0;
|
||||
|
|
|
@ -1,6 +1,14 @@
|
|||
=======================================================================
|
||||
Xash3D QuakeC Compiler started at Nov11 2007 [00:36.22]
|
||||
Xash3D QuakeC Compiler started at Nov11 2007 [17:22.24]
|
||||
=======================================================================
|
||||
Sys_LoadLibrary: Loading launch.dll - ok
|
||||
CPU: AuthenticAMD [1 core]. Frequency: 1.8 Ghz
|
||||
CPU Features: MMX 3DNow SSE SSE2 RDTSC CMOV FCMOV
|
||||
FS_Init: game directory "qcclib" not exist. Use default gamedir "xash".
|
||||
FS_Init: done
|
||||
Sys_LoadLibrary: Loading common.dll - ok
|
||||
Current search path:
|
||||
./
|
||||
------------Configuration: server - Vm16 Release------------
|
||||
Compiling...
|
||||
defs.c
|
||||
|
@ -36,11 +44,20 @@ ents/items/items.c
|
|||
impulses.c
|
||||
Custom progs crc 64081
|
||||
Linking...
|
||||
19684 strofs (of 1000000)
|
||||
2873 numstatements (of 524288)
|
||||
284 numfunctions (of 16384)
|
||||
956 numglobaldefs (of 32768)
|
||||
245 numfielddefs (218 unique) (of 2048)
|
||||
2272 numpr_globals (of 65536)
|
||||
Writing server.dat, total size 71832 bytes
|
||||
‘ª®¯¨à®¢ ® ä ©«®¢: 1.
|
||||
|
||||
server.dat - 0 error(s), 0 warning(s)
|
||||
0.236 seconds elapsed
|
||||
0.335 seconds elapsed
|
||||
Sys_FreeLibrary: Unloading common.dll
|
||||
Sys_FreeLibrary: Unloading launch.dll
|
||||
|
||||
=======================================================================
|
||||
Xash3D QuakeC Compiler stopped at Nov11 2007 [00:36.22]
|
||||
Xash3D QuakeC Compiler stopped at Nov11 2007 [17:22.24]
|
||||
=======================================================================
|
|
@ -1,2 +1,2 @@
|
|||
qcclib -log /O3 /V7 -log
|
||||
qcclib -log /0d /V7 -dev 5 -debug
|
||||
pause
|
Binary file not shown.
Reference in New Issue