mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 21:57:57 +03:00
Reworked source tree so it compiles
This commit is contained in:
parent
19e33444e7
commit
8ef16a91f2
164 changed files with 3183 additions and 20134 deletions
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// skeletor_imports.cpp : Skeletor imports
|
||||
|
||||
#include "q_shared.h"
|
||||
#include "qcommon.h"
|
||||
#include "dbgheap.h"
|
||||
|
||||
void Skel_DPrintf( const char *fmt, ... )
|
||||
{
|
||||
char msg[ 4096 ];
|
||||
va_list va;
|
||||
|
||||
va_start( va, fmt );
|
||||
vsprintf( msg, fmt, va );
|
||||
va_end( va );
|
||||
|
||||
Com_DPrintf( "%s", msg );
|
||||
}
|
||||
|
||||
#ifndef _DEBUG_MEM
|
||||
|
||||
void Skel_Free( void *ptr )
|
||||
{
|
||||
Z_Free( ptr );
|
||||
}
|
||||
|
||||
void *Skel_Alloc( size_t size )
|
||||
{
|
||||
return Z_TagMalloc( size, TAG_SKEL );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void Skel_FreeFile( void *buffer )
|
||||
{
|
||||
FS_FreeFile( buffer );
|
||||
}
|
||||
|
||||
int Skel_ReadFileEx( const char *qpath, void **buffer, qboolean quiet )
|
||||
{
|
||||
return FS_ReadFileEx( qpath, buffer, quiet );
|
||||
}
|
|
@ -28,6 +28,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "g_local.h"
|
||||
#include "simpleactor.h"
|
||||
#include "actorenemy.h"
|
||||
#include "level.h"
|
||||
#include "game.h"
|
||||
#include <gamescript.h>
|
||||
#include <scriptmaster.h>
|
||||
#include "grenadehint.h"
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "glb_local.h"
|
||||
#include "archive.h"
|
||||
#include "level.h"
|
||||
#include <lz77.h>
|
||||
|
||||
#ifdef GAME_DLL
|
|
@ -1,487 +0,0 @@
|
|||
//
|
||||
// b_files.c
|
||||
//
|
||||
|
||||
|
||||
#include "b_local.h"
|
||||
|
||||
#if 0
|
||||
//
|
||||
// parse support routines
|
||||
//
|
||||
|
||||
static qboolean Nav_ParseLiteral( char **data, const char *string ) {
|
||||
char *token;
|
||||
|
||||
token = COM_ParseExt( data, qtrue );
|
||||
if ( token[0] == 0 ) {
|
||||
gi.Printf( ERROR "unexpected EOF\n" );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
if ( Q_stricmp( token, string ) ) {
|
||||
gi.Printf( ERROR "required string '%s' missing\n", string );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
static qboolean Nav_ParseString( char **data, char **s ) {
|
||||
*s = COM_ParseExt( data, qfalse );
|
||||
if ( s[0] == 0 ) {
|
||||
gi.Printf( ERROR "unexpected EOF\n" );
|
||||
return qtrue;
|
||||
}
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
static qboolean Nav_ParseInt( char **data, int *i ) {
|
||||
char *token;
|
||||
|
||||
token = COM_ParseExt( data, qfalse );
|
||||
if ( token[0] == 0 ) {
|
||||
gi.Printf( ERROR "unexpected EOF\n" );
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
*i = atoi( token );
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// bot parameters file : scripts/bots.cfg
|
||||
//
|
||||
|
||||
char botParms[0x10000];
|
||||
|
||||
|
||||
static int MethodNameToNumber( const char *name ) {
|
||||
if ( !Q_stricmp( name, "EXPONENTIAL" ) ) {
|
||||
return METHOD_EXPONENTIAL;
|
||||
}
|
||||
if ( !Q_stricmp( name, "LINEAR" ) ) {
|
||||
return METHOD_LINEAR;
|
||||
}
|
||||
if ( !Q_stricmp( name, "LOGRITHMIC" ) ) {
|
||||
return METHOD_LOGRITHMIC;
|
||||
}
|
||||
if ( !Q_stricmp( name, "ALWAYS" ) ) {
|
||||
return METHOD_ALWAYS;
|
||||
}
|
||||
if ( !Q_stricmp( name, "NEVER" ) ) {
|
||||
return METHOD_NEVER;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
static int ItemNameToNumber( const char *name, int itemType ) {
|
||||
int n;
|
||||
|
||||
for ( n = 0; n < bg_numItems; n++ ) {
|
||||
if ( bg_itemlist[n].type != itemType ) {
|
||||
continue;
|
||||
}
|
||||
if ( Q_stricmp( bg_itemlist[n].classname, name ) == 0 ) {
|
||||
return bg_itemlist[n].tag;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
void Bot_ParseParms( const char *botName, gentity_t *bot, char *userinfo ) {
|
||||
char *token;
|
||||
char *value;
|
||||
char *p;
|
||||
int n;
|
||||
int count;
|
||||
|
||||
if ( !botName || !botName[0]) {
|
||||
botName = "Player";
|
||||
}
|
||||
|
||||
strcpy( userinfo, "\\name\\" );
|
||||
strcat( userinfo, botName );
|
||||
|
||||
// fill in defaults
|
||||
bot->bot->reactions = 3;
|
||||
bot->bot->aim = 3;
|
||||
bot->bot->move = 3;
|
||||
bot->bot->aggression = 3;
|
||||
bot->bot->intelligence = 3;
|
||||
bot->bot->hfov = 90 / 2;
|
||||
bot->bot->vfov = 68 / 2;
|
||||
bot->bot->healthMethod = METHOD_LOGRITHMIC;
|
||||
bot->bot->armorMethod = METHOD_LINEAR;
|
||||
bot->bot->ammoMethod = METHOD_EXPONENTIAL;
|
||||
bot->bot->allWeaponOrder[0] = WP_BFG;
|
||||
bot->bot->allWeaponOrder[1] = WP_ROCKET_LAUNCHER;
|
||||
bot->bot->allWeaponOrder[2] = WP_RAILGUN;
|
||||
bot->bot->allWeaponOrder[3] = WP_PLASMAGUN;
|
||||
bot->bot->allWeaponOrder[4] = WP_GRENADE_LAUNCHER;
|
||||
bot->bot->allWeaponOrder[5] = WP_SHOTGUN;
|
||||
bot->bot->allWeaponOrder[6] = WP_MACHINEGUN;
|
||||
bot->bot->allWeaponOrder[7] = WP_NONE;
|
||||
|
||||
p = botParms;
|
||||
COM_BeginParseSession();
|
||||
|
||||
// look for the right bot
|
||||
while ( p ) {
|
||||
token = COM_ParseExt( &p, qtrue );
|
||||
if ( token[0] == 0 )
|
||||
return;
|
||||
|
||||
if ( !Q_stricmp( token, botName ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
SkipBracedSection( &p );
|
||||
}
|
||||
if ( !p ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( Nav_ParseLiteral( &p, "{" ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// parse the bot info block
|
||||
while ( 1 ) {
|
||||
token = COM_ParseExt( &p, qtrue );
|
||||
if ( !token[0] ) {
|
||||
gi.Printf( "ERROR: unexpected EOF while parsing '%s'\n", botName );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !Q_stricmp( token, "}" ) ) {
|
||||
break;
|
||||
}
|
||||
|
||||
// model
|
||||
if ( !Q_stricmp( token, "model" ) ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
continue;
|
||||
}
|
||||
strcat ( userinfo, "\\model\\" );
|
||||
strcat ( userinfo, value );
|
||||
continue;
|
||||
}
|
||||
|
||||
// reactions
|
||||
if ( !Q_stricmp( token, "reactions" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 1 || n > 5 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->reactions = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// aim
|
||||
if ( !Q_stricmp( token, "aim" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 1 || n > 5 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->aim = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// move
|
||||
if ( !Q_stricmp( token, "move" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 1 || n > 5 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->move = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// aggression
|
||||
if ( !Q_stricmp( token, "aggression" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 1 || n > 5 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->aggression = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// intelligence
|
||||
if ( !Q_stricmp( token, "intelligence" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 1 || n > 5 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->intelligence = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// hfov
|
||||
if ( !Q_stricmp( token, "hfov" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 30 || n > 180 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->hfov = n / 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// vfov
|
||||
if ( !Q_stricmp( token, "vfov" ) ) {
|
||||
if ( Nav_ParseInt( &p, &n ) ) {
|
||||
SkipRestOfLine( &p );
|
||||
continue;
|
||||
}
|
||||
if ( n < 30 || n > 180 ) {
|
||||
gi.Printf( WARNING "bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->vfov = n / 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
// healthMethod
|
||||
if ( !Q_stricmp( token, "healthMethod" ) ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
continue;
|
||||
}
|
||||
n = MethodNameToNumber( value );
|
||||
if ( n == -1 ) {
|
||||
gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->healthMethod = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// armorMethod
|
||||
if ( !Q_stricmp( token, "armorMethod" ) ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
continue;
|
||||
}
|
||||
n = MethodNameToNumber( value );
|
||||
if ( n == -1 ) {
|
||||
gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->armorMethod = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// ammoMethod
|
||||
if ( !Q_stricmp( token, "ammoMethod" ) ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
continue;
|
||||
}
|
||||
n = MethodNameToNumber( value );
|
||||
if ( n == -1 ) {
|
||||
gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->ammoMethod = n;
|
||||
continue;
|
||||
}
|
||||
|
||||
// weapons
|
||||
if ( !Q_stricmp( token, "weapons" ) ) {
|
||||
for ( count = 0; count < MAX_WEAPONS; count++ ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
break;
|
||||
}
|
||||
if ( *value == 0 ) {
|
||||
break;
|
||||
}
|
||||
n = ItemNameToNumber( value, IT_WEAPON );
|
||||
if ( n == -1 ) {
|
||||
gi.Printf( "WARNING: bad %s in bot '%s'\n", token, botName );
|
||||
continue;
|
||||
}
|
||||
bot->bot->allWeaponOrder[count] = n;
|
||||
}
|
||||
if ( count < MAX_WEAPONS ) {
|
||||
bot->bot->allWeaponOrder[count] = WP_NONE;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
// snd
|
||||
if ( !Q_stricmp( token, "snd" ) ) {
|
||||
if ( Nav_ParseString( &p, &value ) ) {
|
||||
continue;
|
||||
}
|
||||
strcat( userinfo, "\\snd\\" );
|
||||
strcat( userinfo, value );
|
||||
continue;
|
||||
}
|
||||
|
||||
gi.Printf( "WARNING: unknown keyword '%s' while parsing '%s'\n", token, botName );
|
||||
SkipRestOfLine( &p );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Bot_LoadParms( void ) {
|
||||
int len;
|
||||
char filename[MAX_QPATH];
|
||||
char *buffer;
|
||||
|
||||
sprintf( filename, "scripts/bots.cfg" );
|
||||
gi.Printf( "Parsing %s\n", filename );
|
||||
len = gi.FS_ReadFile( filename, &buffer, qtrue );
|
||||
if ( len == -1 ) {
|
||||
gi.Printf( "file not found\n" );
|
||||
}
|
||||
|
||||
if ( len >= sizeof( botParms ) ) {
|
||||
gi.Error( ERR_DROP, "scripts/bots.cfg is too large" );
|
||||
}
|
||||
strncpy( botParms, buffer, sizeof( botParms ) - 1 );
|
||||
gi.FS_FreeFile( buffer );
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// navigation data : maps/*.nav
|
||||
//
|
||||
|
||||
void Nav_LoadRoutes( void ) {
|
||||
int len;
|
||||
navheader_t *header;
|
||||
int value;
|
||||
int n;
|
||||
str filename;
|
||||
|
||||
Swap_Init();
|
||||
|
||||
surfaceCount = 0;
|
||||
surface = NULL;
|
||||
neighborCount = 0;
|
||||
neighbor = NULL;
|
||||
|
||||
// load the file
|
||||
filename = "maps/";
|
||||
filename += level.mapname + ".nav";
|
||||
|
||||
gi.Printf( "Loading %s\n", filename.c_str() );
|
||||
len = gi.FS_ReadFile( filename.c_str(), ( void ** )&navFileData, qtrue );
|
||||
if ( len == -1 ) {
|
||||
gi.Printf( WARNING "no navigation data\n" );
|
||||
return;
|
||||
}
|
||||
if ( len < sizeof( navheader_t ) ) {
|
||||
gi.Printf( ERROR "no nav file header\n" );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
// process the header
|
||||
header = (navheader_t *)navFileData;
|
||||
header->id = LittleLong( header->id );
|
||||
header->version = LittleLong( header->version );
|
||||
header->surfaceCount = LittleLong( header->surfaceCount );
|
||||
header->neighborCount = LittleLong( header->neighborCount );
|
||||
|
||||
// validate the header fields
|
||||
if ( header->id != NAVFILE_ID ) {
|
||||
gi.Printf( ERROR "incorrect nav file id\n" );
|
||||
goto cleanup;
|
||||
}
|
||||
if ( header->version != NAVFILE_VERSION ) {
|
||||
gi.Printf( ERROR "incorrect nav file version (%i, should be %i)\n", header->version, NAVFILE_VERSION );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
value = /* header */ sizeof( navheader_t ) +
|
||||
/* surfaces */ header->surfaceCount * sizeof( nsurface_t ) +
|
||||
/* neighbors */ header->neighborCount * sizeof( nneighbor_t ) +
|
||||
/* routes */ header->surfaceCount * header->surfaceCount * sizeof( byte );
|
||||
|
||||
if ( value != len ) {
|
||||
gi.Printf( ERROR "incorrect nav file length (%i, should be %i)\n", len, value );
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
surfaceCount = header->surfaceCount;
|
||||
neighborCount = header->neighborCount;
|
||||
|
||||
// process surfaces
|
||||
surface = (nsurface_t *)(navFileData + sizeof( navheader_t ) );
|
||||
for ( n = 0; n < surfaceCount; n++ ) {
|
||||
surface[n].origin[0] = LittleFloat( surface[n].origin[0] );
|
||||
surface[n].origin[1] = LittleFloat( surface[n].origin[1] );
|
||||
surface[n].origin[2] = LittleFloat( surface[n].origin[2] );
|
||||
|
||||
surface[n].absmin[0] = LittleFloat( surface[n].absmin[0] );
|
||||
surface[n].absmin[1] = LittleFloat( surface[n].absmin[1] );
|
||||
|
||||
surface[n].absmax[0] = LittleFloat( surface[n].absmax[0] );
|
||||
surface[n].absmax[1] = LittleFloat( surface[n].absmax[1] );
|
||||
|
||||
surface[n].flags = LittleLong( surface[n].flags );
|
||||
surface[n].neighborCount = LittleLong( surface[n].neighborCount );
|
||||
surface[n].neighborIndex = LittleLong( surface[n].neighborIndex );
|
||||
surface[n].parm = LittleLong( surface[n].parm );
|
||||
}
|
||||
|
||||
// process neighbors
|
||||
neighbor = (nneighbor_t *)((byte *)surface + surfaceCount * sizeof( nsurface_t ));
|
||||
for ( n = 0; n < neighborCount; n++ ) {
|
||||
neighbor[n].origin[0] = LittleFloat( neighbor[n].origin[0] );
|
||||
neighbor[n].origin[1] = LittleFloat( neighbor[n].origin[1] );
|
||||
neighbor[n].origin[2] = LittleFloat( neighbor[n].origin[2] );
|
||||
|
||||
neighbor[n].absmin[0] = LittleFloat( neighbor[n].absmin[0] );
|
||||
neighbor[n].absmin[1] = LittleFloat( neighbor[n].absmin[1] );
|
||||
|
||||
neighbor[n].absmax[0] = LittleFloat( neighbor[n].absmax[0] );
|
||||
neighbor[n].absmax[1] = LittleFloat( neighbor[n].absmax[1] );
|
||||
|
||||
neighbor[n].surfaceNum = LittleLong( neighbor[n].surfaceNum );
|
||||
neighbor[n].flags = LittleLong( neighbor[n].flags );
|
||||
neighbor[n].cost = LittleLong( neighbor[n].cost );
|
||||
neighbor[n].filler = LittleLong( neighbor[n].filler );
|
||||
}
|
||||
|
||||
// process routes
|
||||
route = (byte *)neighbor + neighborCount * sizeof( nneighbor_t );
|
||||
|
||||
gi.Printf( "...loaded %i surfaces and %i neighbors\n", surfaceCount, neighborCount );
|
||||
return;
|
||||
|
||||
cleanup:
|
||||
gi.FS_FreeFile ( navFileData );
|
||||
navFileData = NULL;
|
||||
}
|
|
@ -1,167 +0,0 @@
|
|||
#ifndef __B_LOCAL_H__
|
||||
#define __B_LOCAL_H__
|
||||
|
||||
#include "g_local.h"
|
||||
|
||||
//
|
||||
// This section should be moved to QFILES.H
|
||||
//
|
||||
|
||||
#define NAVFILE_ID (('I')+('N'<<8)+('A'<<16)+('V'<<24))
|
||||
#define NAVFILE_VERSION 2
|
||||
|
||||
typedef struct {
|
||||
unsigned id;
|
||||
unsigned version;
|
||||
unsigned surfaceCount;
|
||||
unsigned neighborCount;
|
||||
} navheader_t;
|
||||
|
||||
|
||||
#define MAX_SURFACES 4096
|
||||
|
||||
#define SF_PUSH 0x00000001
|
||||
#define SF_WATERLEVEL1 0x00000002
|
||||
#define SF_WATERLEVEL2 0x00000004
|
||||
#define SF_WATER_NOAIR 0x00000008
|
||||
#define SF_DUCK 0x00000010
|
||||
#define SF_PAIN 0x00000020
|
||||
#define SF_TELEPORTER 0x00000040
|
||||
#define SF_PLATHIGH 0x00000080
|
||||
#define SF_PLATLOW 0x00000100
|
||||
|
||||
typedef struct {
|
||||
vec3_t origin;
|
||||
vec2_t absmin;
|
||||
vec2_t absmax;
|
||||
int parm;
|
||||
unsigned flags;
|
||||
unsigned neighborCount;
|
||||
unsigned neighborIndex;
|
||||
} nsurface_t;
|
||||
|
||||
|
||||
#define MAX_NEIGHBORS 16384
|
||||
|
||||
#define NF_JUMP 0x00000001
|
||||
#define NF_DUCK 0x00000002
|
||||
#define NF_PLAT 0x00000004
|
||||
#define NF_FALL1 0x00000008
|
||||
#define NF_FALL2 0x00000010
|
||||
|
||||
typedef struct {
|
||||
vec3_t origin;
|
||||
vec2_t absmin; // region within this surface that is the portal to the other surface
|
||||
vec2_t absmax;
|
||||
int surfaceNum;
|
||||
unsigned flags; // jump, prerequisite button, will take falling damage, etc...
|
||||
float cost;
|
||||
unsigned filler; // to be used as a "string index" into an array of targetnames for buttons, etc
|
||||
} nneighbor_t;
|
||||
|
||||
#define WARNING "\033" "3" "WARNING: "
|
||||
#define ERROR "\033" "1" "ERROR: "
|
||||
|
||||
|
||||
// file buffers
|
||||
|
||||
extern char botParms[0x10000];
|
||||
extern char *navFileData;
|
||||
|
||||
|
||||
//
|
||||
// Navigation susbsystem
|
||||
//
|
||||
|
||||
#define NAVF_DUCK 0x00000001
|
||||
#define NAVF_JUMP 0x00000002
|
||||
#define NAVF_HOLD 0x00000004
|
||||
#define NAVF_SLOW 0x00000008
|
||||
|
||||
#define METHOD_EXPONENTIAL 1
|
||||
#define METHOD_LINEAR 2
|
||||
#define METHOD_LOGRITHMIC 3
|
||||
#define METHOD_ALWAYS 4
|
||||
#define METHOD_NEVER 5
|
||||
|
||||
// combat maneuvers
|
||||
#define CM_NONE 0
|
||||
|
||||
#define CM_CLOSE_DISTANCE 1
|
||||
#define CM_OPEN_DISTANCE 2
|
||||
#define CM_HOLD_DISTANCE 3
|
||||
|
||||
#define CM_GET_ITEM 4
|
||||
#define CM_RUN_AWAY 5
|
||||
|
||||
#define CM_CIRCLE 6
|
||||
#define CM_DUCK 7
|
||||
|
||||
typedef enum {SPOT_ORIGIN, SPOT_HEAD, SPOT_WEAPON, SPOT_LEGS, SPOT_GROUND} spot_t;
|
||||
|
||||
#define BOT_TIME_TO_LOSE_SIGHT 2000
|
||||
|
||||
#define SF_FROMMAPFILE 0x80000000
|
||||
|
||||
#define DEBUG_LEVEL_DETAIL 4
|
||||
#define DEBUG_LEVEL_INFO 3
|
||||
#define DEBUG_LEVEL_WARNING 2
|
||||
#define DEBUG_LEVEL_ERROR 1
|
||||
#define DEBUG_LEVEL_NONE 0
|
||||
|
||||
|
||||
//
|
||||
// b_main.c
|
||||
//
|
||||
void Debug_Printf( cvar_t *cv, int level, char *fmt, ... );
|
||||
void Debug_BotPrintf( gentity_t *bot, cvar_t *cv, int debugLevel, char *fmt, ... );
|
||||
|
||||
|
||||
//
|
||||
// b_ai.c
|
||||
//
|
||||
extern cvar_t *debugBotAI;
|
||||
extern cvar_t *debugBotFreeze;
|
||||
|
||||
void Bot_InitAI( void );
|
||||
void Bot_Pain( gentity_t *bot, gentity_t *other, int damage );
|
||||
void Bot_Touch( gentity_t *bot, gentity_t *other, trace_t *trace );
|
||||
void BotSpawn( gentity_t *bot );
|
||||
void Bot_Fetch_f( void );
|
||||
|
||||
//
|
||||
// b_nav.c
|
||||
//
|
||||
extern char *navFileData;
|
||||
extern int surfaceCount;
|
||||
extern nsurface_t *surface;
|
||||
extern int neighborCount;
|
||||
extern nneighbor_t *neighbor;
|
||||
extern byte *route;
|
||||
|
||||
|
||||
void Nav_InitPreSpawn( void );
|
||||
void Nav_InitPostSpawn( void );
|
||||
void Nav_Shutdown( void );
|
||||
void Nav_ShowPath( gentity_t *bot );
|
||||
int Nav_GroundSurfaceNumber( gentity_t *ent );
|
||||
int Nav_ItemSurfaceNumber( gentity_t *ent );
|
||||
int Nav_EntitySurfaceNumber( gentity_t *ent );
|
||||
int Nav_MoveToGoal( gentity_t *bot, vec3_t dir, int *flags );
|
||||
|
||||
//
|
||||
// b_items.c
|
||||
//
|
||||
void Nav_InitRoamList( void );
|
||||
qboolean WeaponIsOnLevel( int weapon );
|
||||
gentity_t *Nav_ChooseRoamGoal( void );
|
||||
|
||||
//
|
||||
// b_files.c
|
||||
//
|
||||
void Bot_ParseParms( const char *botName, gentity_t *bot, char *userinfo );
|
||||
void Bot_LoadParms( void );
|
||||
void Nav_LoadRoutes( void );
|
||||
void Nav_SaveRoutes( void );
|
||||
|
||||
#endif
|
|
@ -1,632 +0,0 @@
|
|||
|
||||
//
|
||||
// b_nav.c
|
||||
//
|
||||
|
||||
//FIXME make botInfo, etc visible here too and get rid of all the mutliple dereferences like bot->bot->
|
||||
|
||||
#include "b_local.h"
|
||||
|
||||
|
||||
#define NAVF_EDGEZONE 0x00000001
|
||||
|
||||
#define INFINITE 1000000
|
||||
|
||||
#define BOTAI_PUSHED (1<<0)
|
||||
|
||||
cvar_t *nav_showsectors;
|
||||
|
||||
char *navFileData;
|
||||
|
||||
int surfaceCount;
|
||||
nsurface_t *surface;
|
||||
int neighborCount;
|
||||
nneighbor_t *neighbor;
|
||||
byte *route;
|
||||
|
||||
//#if 0
|
||||
|
||||
static int spawnpadModelIndex;
|
||||
|
||||
|
||||
int Nav_SurfaceUnderPlayer( gentity_t *player ) {
|
||||
vec3_t start;
|
||||
vec3_t end;
|
||||
vec3_t p;
|
||||
trace_t tr;
|
||||
float bestDist;
|
||||
int bestSurf;
|
||||
vec3_t v;
|
||||
int n;
|
||||
float dist;
|
||||
|
||||
VectorCopy( player->s.origin, start );
|
||||
VectorCopy( player->s.origin, end );
|
||||
end[2] -= 4096;
|
||||
|
||||
gi.trace ( &tr, start, player->mins, player->maxs, end, player->s.number, MASK_DEADSOLID, true );
|
||||
|
||||
// p[0] = ((int)tr.endpos[0] + 8) & (~16);
|
||||
// p[1] = ((int)tr.endpos[1] + 8) & (~16);
|
||||
p[0] = tr.endpos[0];
|
||||
p[1] = tr.endpos[1];
|
||||
p[2] = floor(tr.endpos[2]+player->mins[2]);
|
||||
|
||||
bestDist = INFINITE;
|
||||
bestSurf = -1;
|
||||
|
||||
for ( n = 0; n < surfaceCount; n++ ) {
|
||||
if ( Q_fabs( surface[n].origin[2] - p[2] ) > 24 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VectorSubtract( p, surface[n].origin, v );
|
||||
dist = VectorLength( v );
|
||||
if ( dist < bestDist ) {
|
||||
bestDist = dist;
|
||||
bestSurf = n;
|
||||
}
|
||||
|
||||
if ( surface[n].origin[2] != p[2] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmin[0] > p[0] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmax[0] < p[0] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmin[1] > p[1] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmax[1] < p[1] ) {
|
||||
continue;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// gi.Printf( "guess for %s at %s\n", ent->classname, vtos( p ) );
|
||||
return bestSurf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
Nav_GroundSurfaceNumber
|
||||
|
||||
Returns the surface number for where an entity is currently located.
|
||||
If the entity is not on the ground, it returns -1.
|
||||
|
||||
FIXME we can make this more efficient
|
||||
right now surfaces are in Z sorted order
|
||||
we could make a Z index and binary search it to get to right z group fast
|
||||
=============
|
||||
*/
|
||||
int Nav_GroundSurfaceNumber( gentity_t *ent ) {
|
||||
vec3_t p;
|
||||
vec3_t v;
|
||||
int n;
|
||||
float dist;
|
||||
float bestDist;
|
||||
int bestSurf;
|
||||
gentity_t *groundEntity;
|
||||
|
||||
// if ent is not on the ground it is not on a surface
|
||||
if ( ent->s.groundEntityNum == -1 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// p[0] = ((int)ent->s.origin[0] + 8) & (~16);
|
||||
// p[1] = ((int)ent->s.origin[1] + 8) & (~16);
|
||||
p[0] = ent->s.origin[0];
|
||||
p[1] = ent->s.origin[1];
|
||||
p[2] = floor(ent->s.origin[2]+ent->mins[2]);
|
||||
|
||||
// if ground is not the world we need to handle it differently.
|
||||
if ( ent->s.groundEntityNum != ENTITYNUM_WORLD ) {
|
||||
groundEntity = &g_entities[ent->s.groundEntityNum];
|
||||
|
||||
// check for sitting on a spawn pad
|
||||
if ( !groundEntity->bmodel && groundEntity->s.modelindex == spawnpadModelIndex ) {
|
||||
p[2] -= 8.0;
|
||||
}
|
||||
// check for plats
|
||||
/* else if ( groundEntity->bmodel && Q_stricmp( groundEntity->classname, "func_plat" ) == 0 ) {
|
||||
// if at the top the return PLATHIGH surface number, otherwise return PLATLOW surface number
|
||||
if ( VectorCompare( groundEntity->currentOrigin, groundEntity->pos2 ) ) {
|
||||
return surface[groundEntity->navSurfaceNum].parm;
|
||||
}
|
||||
return groundEntity->navSurfaceNum;
|
||||
} */
|
||||
}
|
||||
|
||||
bestDist = INFINITE;
|
||||
bestSurf = -1;
|
||||
|
||||
for ( n = 0; n < surfaceCount; n++ ) {
|
||||
if ( Q_fabs( surface[n].origin[2] - p[2] ) > 24 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
VectorSubtract( p, surface[n].origin, v );
|
||||
dist = VectorLength( v );
|
||||
if ( dist < bestDist ) {
|
||||
bestDist = dist;
|
||||
bestSurf = n;
|
||||
}
|
||||
|
||||
if ( surface[n].origin[2] != p[2] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmin[0] > p[0] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmax[0] < p[0] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmin[1] > p[1] ) {
|
||||
continue;
|
||||
}
|
||||
if ( surface[n].absmax[1] < p[1] ) {
|
||||
continue;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
// gi.Printf( "guess for %s at %s\n", ent->classname, vtos( p ) );
|
||||
return bestSurf;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
Nav_ItemSurfaceNumber
|
||||
|
||||
Returns the surface number for where an item entity is currently located.
|
||||
If the entity is not on the ground, it returns -1. This is a specialized
|
||||
copy of Nav_GroundSurfaceNumber for items that caches the result.
|
||||
=============
|
||||
*/
|
||||
int Nav_ItemSurfaceNumber( gentity_t *ent ) {
|
||||
if ( !VectorCompare( ent->s.origin, ent->navOrigin ) && level.time > ent->navTime ) {
|
||||
VectorCopy( ent->s.origin, ent->navOrigin );
|
||||
ent->navTime = level.time;
|
||||
ent->navSurfaceNum = Nav_GroundSurfaceNumber( ent );
|
||||
}
|
||||
return ent->navSurfaceNum;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
Nav_EntitySurfaceNumber
|
||||
=============
|
||||
*/
|
||||
int Nav_EntitySurfaceNumber( gentity_t *ent ) {
|
||||
if ( ent->s.eType == ET_ITEM ) {
|
||||
return Nav_ItemSurfaceNumber( ent );
|
||||
}
|
||||
|
||||
/*if ( ent->classname&& strcmp( ent->classname, "bot_goal" ) == 0 ) {
|
||||
return Nav_SurfaceUnderPlayer( ent );
|
||||
}*/
|
||||
|
||||
return Nav_GroundSurfaceNumber( ent );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
PathEdge
|
||||
=============
|
||||
*/
|
||||
|
||||
static nneighbor_t *PathEdge( int sourceSurfNum, int destSurfNum ) {
|
||||
int base;
|
||||
int n;
|
||||
|
||||
base = surface[sourceSurfNum].neighborIndex;
|
||||
for ( n = 0; n < surface[sourceSurfNum].neighborCount; n++ ) {
|
||||
if ( neighbor[base+n].surfaceNum == destSurfNum ) {
|
||||
return &neighbor[base+n];
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=============
|
||||
PointIsInEdgeRegion
|
||||
=============
|
||||
*/
|
||||
|
||||
static qboolean PointIsInEdgeRegion( vec3_t p, nneighbor_t *n ) {
|
||||
if ( p[0] < n->absmin[0] ) {
|
||||
return qfalse;
|
||||
}
|
||||
if ( p[0] > n->absmax[0] ) {
|
||||
return qfalse;
|
||||
}
|
||||
if ( p[1] < n->absmin[1] ) {
|
||||
return qfalse;
|
||||
}
|
||||
if ( p[1] > n->absmax[1] ) {
|
||||
return qfalse;
|
||||
}
|
||||
return qtrue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
=============
|
||||
Nav_MoveToGoal
|
||||
=============
|
||||
*/
|
||||
|
||||
int Nav_MoveToGoal( gentity_t *bot, vec3_t dir, int *flags ) {
|
||||
int currentSurf;
|
||||
int nextSurf;
|
||||
int thirdSurf;
|
||||
int goalSurf;
|
||||
int routeIndex;
|
||||
nneighbor_t *edge;
|
||||
nneighbor_t *nextEdge;
|
||||
//gentity_t *ent;
|
||||
//float dist;
|
||||
|
||||
*flags = 0;
|
||||
VectorCopy( bot->navDir, dir );
|
||||
|
||||
currentSurf = bot->currentSurface;
|
||||
|
||||
// if bot is airborne, just keep heading the same
|
||||
if ( currentSurf == -1 ) {
|
||||
if ( bot->aiFlags & BOTAI_PUSHED ) {
|
||||
//gi.Printf( "bot was bounced\n" );
|
||||
*flags |= NAVF_HOLD;
|
||||
}
|
||||
//gi.Printf( "not on ground\n" );
|
||||
return 0;
|
||||
}
|
||||
if ( bot->pushedTime < level.time ) {
|
||||
bot->aiFlags &= ~BOTAI_PUSHED;
|
||||
}
|
||||
|
||||
if ( !bot->goalEntity ) {
|
||||
// gi.Printf( ERROR "Nav_MoveToGoal called with no goalEntity set\n" );
|
||||
return -1;
|
||||
}
|
||||
|
||||
goalSurf = Nav_EntitySurfaceNumber( bot->goalEntity );
|
||||
if ( goalSurf == -1 ) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
// if we've changed surfaces, the surface to surface navigation flags and timer need to be cleared
|
||||
if ( currentSurf != bot->lastSurface ) {
|
||||
bot->navFlags = 0;
|
||||
bot->navTime = 0;
|
||||
//gi.Printf( "surface changed from %i to %i\n", bot->bot->lastSurface, bot->bot->currentSurface );
|
||||
}
|
||||
|
||||
if ( currentSurf == goalSurf ) {
|
||||
//gi.Printf( "On target surface\n" );
|
||||
VectorSubtract( bot->goalEntity->s.origin, bot->s.origin, dir );
|
||||
//VectorCopy( dir, bot->bot->navDir );
|
||||
VectorCopy( dir, bot->navDir );
|
||||
return 0;
|
||||
}
|
||||
|
||||
routeIndex = route[currentSurf * surfaceCount + goalSurf];
|
||||
if ( routeIndex == 255 ) {
|
||||
//gi.Printf( "Nav_MoveToGoal - no known route from %i to %i\n", currentSurf, goalSurf );
|
||||
return -1;
|
||||
}
|
||||
if ( routeIndex >= surface[currentSurf].neighborCount ) {
|
||||
gi.Printf( ERROR "Nav_MoveToGoal - bad routeIndex\n" );
|
||||
return -1;
|
||||
}
|
||||
nextSurf = neighbor[surface[currentSurf].neighborIndex + routeIndex].surfaceNum;
|
||||
|
||||
edge = PathEdge( currentSurf, nextSurf );
|
||||
if ( !edge ) {
|
||||
gi.Printf( ERROR "Nav_MoveToGoal - %i does not have %i as a neighbor\n", currentSurf, nextSurf );
|
||||
VectorClear( dir );
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ( ! ( bot->navFlags & NAVF_EDGEZONE ) ) {
|
||||
if ( PointIsInEdgeRegion( bot->s.origin, edge ) ) {
|
||||
//gi.Printf( "hit edge\n" );
|
||||
bot->navFlags |= NAVF_EDGEZONE;
|
||||
bot->navTime = level.time;
|
||||
}
|
||||
}
|
||||
|
||||
// if we are in the edge zone
|
||||
if ( bot->navFlags & NAVF_EDGEZONE ) {
|
||||
// if we're trying to get onto a plat, we must make sure it's there
|
||||
/*if ( surface[nextSurf].flags & SF_PLATLOW ) {
|
||||
ent = &g_entities[surface[surface[nextSurf].parm].parm]; //FIXME this works for now, but I don't like it
|
||||
if ( VectorCompare( ent->currentOrigin, ent->pos1 ) == 0 ) {
|
||||
*flags |= NAVF_HOLD;
|
||||
//gi.Printf(" wait for plat2\n" );
|
||||
}
|
||||
}*/
|
||||
|
||||
// if we're riding up on a plat, we don't need to move
|
||||
if ( surface[nextSurf].flags & SF_PLATHIGH ) {
|
||||
*flags |= NAVF_HOLD;
|
||||
//gi.Printf(" hold on plat\n" );
|
||||
}
|
||||
|
||||
// if the next surface contains the goalEntity, head towards it
|
||||
if ( nextSurf == goalSurf ) {
|
||||
//gi.Printf( "next surf has goal - targeting directly\n" );
|
||||
VectorSubtract( bot->goalEntity->s.origin, bot->s.origin, dir );
|
||||
//VectorCopy( dir, bot->bot->navDir );
|
||||
VectorCopy( dir, bot->navDir );
|
||||
}
|
||||
// start heading towards the next edge
|
||||
else {
|
||||
routeIndex = route[nextSurf * surfaceCount + goalSurf];
|
||||
if ( routeIndex == 255 ) {
|
||||
gi.Printf( ERROR "Nav_MoveToGoal - no known route from %i to %i\n", nextSurf, goalSurf );
|
||||
return -1;
|
||||
}
|
||||
if ( routeIndex >= surface[nextSurf].neighborCount ) {
|
||||
gi.Printf( ERROR "Nav_MoveToGoal - bad routeIndex\n" );
|
||||
return -1;
|
||||
}
|
||||
thirdSurf = neighbor[surface[nextSurf].neighborIndex + routeIndex].surfaceNum;
|
||||
nextEdge = PathEdge( nextSurf, thirdSurf );
|
||||
if ( !nextEdge ) {
|
||||
gi.Printf( ERROR "Nav_MoveToGoal - %i does not have %i as a neighbor\n", nextSurf, thirdSurf );
|
||||
VectorClear( dir );
|
||||
return -1;
|
||||
}
|
||||
//gi.Printf( "targeting next edge\n" );
|
||||
if ( surface[nextSurf].flags & SF_PLATHIGH ) {
|
||||
VectorSubtract( nextEdge->origin, surface[nextSurf].origin, dir );
|
||||
}
|
||||
else {
|
||||
VectorSubtract( nextEdge->origin, bot->s.origin, dir );
|
||||
}
|
||||
//VectorCopy( dir, bot->bot->navDir );
|
||||
VectorCopy( dir, bot->navDir );
|
||||
}
|
||||
|
||||
if ( edge->flags & NF_DUCK ) {
|
||||
*flags |= NAVF_DUCK;
|
||||
}
|
||||
if ( edge->flags & NF_JUMP ) {
|
||||
*flags |= NAVF_JUMP;
|
||||
}
|
||||
}
|
||||
else {
|
||||
VectorSubtract( edge->origin, bot->s.origin, dir );
|
||||
//VectorCopy( dir, bot->bot->navDir );
|
||||
VectorCopy( dir, bot->navDir );
|
||||
|
||||
/*if ( surface[nextSurf].flags & SF_PLATLOW ) {
|
||||
ent = &g_entities[surface[surface[nextSurf].parm].parm]; //FIXME this works for now, but I don't like it
|
||||
if ( VectorCompare( ent->currentOrigin, ent->pos1 ) == 0 ) {
|
||||
dist = VectorLength( dir );
|
||||
if ( dist > 64 ) {
|
||||
*flags |= NAVF_SLOW;
|
||||
//gi.Printf(" slow for plat\n" );
|
||||
}
|
||||
else {
|
||||
*flags |= NAVF_HOLD;
|
||||
//gi.Printf(" wait for plat\n" );
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
void Nav_ShowPath( gentity_t *bot ) {
|
||||
#if 0
|
||||
gentity_t *tent;
|
||||
int m, n;
|
||||
|
||||
if ( !bot->bot->goalEntity ) {
|
||||
return;
|
||||
}
|
||||
|
||||
tent = G_TempEntity( bot->s.origin, EV_DEBUG_LINE );
|
||||
VectorCopy( bot->bot->currentWaypoint->s.origin, tent->s.origin2 );
|
||||
|
||||
m = bot->bot->currentWaypoint->count;
|
||||
for (;;) {
|
||||
if ( m == bot->bot->finalWaypoint->count ) {
|
||||
break;
|
||||
}
|
||||
n = route[m*maxwaypoints+bot->bot->finalWaypoint->count];
|
||||
if ( n == -1 ) {
|
||||
break;
|
||||
}
|
||||
tent = G_TempEntity( rents[m]->s.origin, EV_DEBUG_LINE );
|
||||
VectorCopy( rents[n]->s.origin, tent->s.origin2 );
|
||||
m = n;
|
||||
}
|
||||
|
||||
if ( bot->bot->finalWaypoint != bot->bot->goalEntity ) {
|
||||
tent = G_TempEntity( bot->bot->finalWaypoint->s.origin, EV_DEBUG_LINE );
|
||||
VectorCopy( bot->bot->goalEntity->s.origin, tent->s.origin2 );
|
||||
}
|
||||
#endif
|
||||
/* gentity_t *tent;
|
||||
int m, n;
|
||||
gentity_t *player;
|
||||
int pSurf;
|
||||
|
||||
player = &g_entities[1];
|
||||
pSurf = Nav_GroundSurfaceNumber( player );
|
||||
|
||||
tent = G_TempEntity( player->s.origin, EV_DEBUG_LINE );
|
||||
VectorCopy( surface[pSurf].origin, tent->s.origin2 ); */
|
||||
}
|
||||
//#endif
|
||||
|
||||
|
||||
/*
|
||||
// Init and Shutdown
|
||||
//
|
||||
//
|
||||
*/
|
||||
|
||||
static void Nav_Cleanup( void ) {
|
||||
if ( navFileData ) {
|
||||
gi.FS_FreeFile ( navFileData );
|
||||
navFileData = NULL;
|
||||
}
|
||||
surfaceCount = 0;
|
||||
neighborCount = 0;
|
||||
}
|
||||
|
||||
void Nav_InitPreSpawn( void ) {
|
||||
nav_showsectors = gi.cvar( "nav_showsectors", "0", 0 );
|
||||
Nav_Cleanup();
|
||||
Nav_LoadRoutes();
|
||||
}
|
||||
|
||||
void Nav_InitPostSpawn( void ) {
|
||||
#if 0
|
||||
int n;
|
||||
nsurface_t *s;
|
||||
gentity_t *ent;
|
||||
|
||||
// FIXME resolve targetnames here (like button needed to open a door)
|
||||
|
||||
// get the modelindex for the spawnpad model so we can use it for surface determination
|
||||
spawnpadModelIndex = G_ModelIndex( "models/objects/dmspot.md3" );
|
||||
|
||||
// set the navSurface for plats
|
||||
for ( n = 0; n < surfaceCount; n++ ) {
|
||||
s = &surface[n];
|
||||
if ( s->flags & SF_PLATLOW ) {
|
||||
ent = &g_entities[surface[s->parm].parm]; //FIXME this works for now, but I don't like it
|
||||
ent->navSurfaceNum = n;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void Nav_Shutdown ( void ) {
|
||||
Nav_Cleanup();
|
||||
}
|
||||
|
||||
void Nav_Test_f( void ) {
|
||||
#if 0
|
||||
gentity_t *player;
|
||||
gentity_t *goal;
|
||||
char *goalname;
|
||||
int pSurf;
|
||||
int gSurf;
|
||||
int cSurf;
|
||||
int n;
|
||||
gentity_t *tent;
|
||||
|
||||
player = &g_entities[0];
|
||||
pSurf = Nav_GroundSurfaceNumber( player );
|
||||
|
||||
goalname = gi.argv(2);
|
||||
if ( !goalname[0] ) {
|
||||
gi.Printf( "Player1 is at (%f, %f, %f) on surface %i\n", player->s.origin[0], player->s.origin[1], player->s.origin[2] + player->mins[2], pSurf );
|
||||
return;
|
||||
}
|
||||
|
||||
goal = NULL;
|
||||
goal = G_Find( goal, FOFS( classname ), goalname );
|
||||
if ( !goal ) {
|
||||
gi.Printf( "no %s on level\n", goalname );
|
||||
return;
|
||||
}
|
||||
gSurf = Nav_EntitySurfaceNumber( goal );
|
||||
|
||||
|
||||
cSurf = pSurf;
|
||||
while ( cSurf != gSurf ) {
|
||||
n = route[cSurf * surfaceCount + gSurf];
|
||||
if ( n == 255 ) {
|
||||
//gi.Printf( "no known route from %i to %i\n", cSurf, gSurf );
|
||||
return;
|
||||
}
|
||||
if ( n >= surface[cSurf].neighborCount ) {
|
||||
gi.Printf( ERROR "bad routeIndex\n" );
|
||||
return;
|
||||
}
|
||||
n = neighbor[surface[cSurf].neighborIndex + n].surfaceNum;
|
||||
|
||||
if ( cSurf == pSurf ) {
|
||||
tent = G_TempEntity( player->s.origin, EV_DEBUG_LINE );
|
||||
}
|
||||
else {
|
||||
tent = G_TempEntity( surface[cSurf].origin, EV_DEBUG_LINE );
|
||||
}
|
||||
if ( n == gSurf ) {
|
||||
VectorCopy( goal->s.origin, tent->s.origin2 );
|
||||
}
|
||||
else {
|
||||
VectorCopy( surface[n].origin, tent->s.origin2 );
|
||||
}
|
||||
|
||||
cSurf = n;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Nav_Gen_f( void );
|
||||
|
||||
void Cmd_Nav_f( void )
|
||||
{
|
||||
char *cmd;
|
||||
|
||||
cmd = gi.argv(1);
|
||||
|
||||
if ( Q_stricmp ( cmd, "gen" ) == 0 ) {
|
||||
Nav_Gen_f();
|
||||
Nav_InitPreSpawn();
|
||||
}
|
||||
else if ( Q_stricmp ( cmd, "test" ) == 0 ) {
|
||||
Nav_Test_f();
|
||||
}
|
||||
else {
|
||||
gi.Printf("Unknown nav command '%s'\n", cmd);
|
||||
}
|
||||
}
|
||||
|
||||
void Nav_ShowStuff
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
int i;
|
||||
nsurface_t *surf;
|
||||
|
||||
if ( !nav_showsectors->integer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
G_Color4f( 1, 1, 0, 1 );
|
||||
for( i = 0; i < surfaceCount; i++ )
|
||||
{
|
||||
surf = &surface[ i ];
|
||||
|
||||
G_BeginLine();
|
||||
G_Vertex( Vector( surf->absmin[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) );
|
||||
G_Vertex( Vector( surf->absmin[ 0 ], surf->absmax[ 1 ], surf->origin[ 2 ] ) );
|
||||
G_Vertex( Vector( surf->absmax[ 0 ], surf->absmax[ 1 ], surf->origin[ 2 ] ) );
|
||||
G_Vertex( Vector( surf->absmax[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) );
|
||||
G_Vertex( Vector( surf->absmin[ 0 ], surf->absmin[ 1 ], surf->origin[ 2 ] ) );
|
||||
G_EndLine();
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load diff
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "barrels.h"
|
||||
#include "weaputils.h"
|
||||
#include "level.h"
|
||||
|
||||
/*****************************************************************************
|
||||
/*QUAKED func_barrel (0 0.25 0.5) ? INDESTRUCTABLE
|
||||
|
|
|
@ -1,210 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_aas.h
|
||||
*
|
||||
* desc: Area Awareness System, stuff exported to the AI
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_aas.h $
|
||||
* $Author: Steven $
|
||||
* $Revision: 2 $
|
||||
* $Modtime: 10/13/03 9:01a $
|
||||
* $Date: 10/13/03 9:11a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef MAX_STRINGFIELD
|
||||
#define MAX_STRINGFIELD 80
|
||||
#endif
|
||||
|
||||
//travel flags
|
||||
#define TFL_INVALID 0x00000001 //traveling temporary not possible
|
||||
#define TFL_WALK 0x00000002 //walking
|
||||
#define TFL_CROUCH 0x00000004 //crouching
|
||||
#define TFL_BARRIERJUMP 0x00000008 //jumping onto a barrier
|
||||
#define TFL_JUMP 0x00000010 //jumping
|
||||
#define TFL_LADDER 0x00000020 //climbing a ladder
|
||||
#define TFL_WALKOFFLEDGE 0x00000080 //walking of a ledge
|
||||
#define TFL_SWIM 0x00000100 //swimming
|
||||
#define TFL_WATERJUMP 0x00000200 //jumping out of the water
|
||||
#define TFL_TELEPORT 0x00000400 //teleporting
|
||||
#define TFL_ELEVATOR 0x00000800 //elevator
|
||||
#define TFL_ROCKETJUMP 0x00001000 //rocket jumping
|
||||
#define TFL_BFGJUMP 0x00002000 //bfg jumping
|
||||
#define TFL_GRAPPLEHOOK 0x00004000 //grappling hook
|
||||
#define TFL_DOUBLEJUMP 0x00008000 //double jump
|
||||
#define TFL_RAMPJUMP 0x00010000 //ramp jump
|
||||
#define TFL_STRAFEJUMP 0x00020000 //strafe jump
|
||||
#define TFL_JUMPPAD 0x00040000 //jump pad
|
||||
#define TFL_AIR 0x00080000 //travel through air
|
||||
#define TFL_WATER 0x00100000 //travel through water
|
||||
#define TFL_SLIME 0x00200000 //travel through slime
|
||||
#define TFL_LAVA 0x00400000 //travel through lava
|
||||
#define TFL_DONOTENTER 0x00800000 //travel through donotenter area
|
||||
#define TFL_FUNCBOB 0x01000000 //func bobbing
|
||||
#define TFL_FLIGHT 0x02000000 //flight
|
||||
#define TFL_BRIDGE 0x04000000 //move over a bridge
|
||||
//
|
||||
#define TFL_NOTTEAM1 0x08000000 //not team 1
|
||||
#define TFL_NOTTEAM2 0x10000000 //not team 2
|
||||
|
||||
//default travel flags
|
||||
#define TFL_DEFAULT TFL_WALK|TFL_CROUCH|TFL_BARRIERJUMP|\
|
||||
TFL_JUMP|TFL_LADDER|\
|
||||
TFL_WALKOFFLEDGE|TFL_SWIM|TFL_WATERJUMP|\
|
||||
TFL_TELEPORT|TFL_ELEVATOR|\
|
||||
TFL_AIR|TFL_WATER|TFL_JUMPPAD|TFL_FUNCBOB
|
||||
|
||||
// already defined in g_public.h in tiki tech, moved to l_util.h so the botlib stuff compiles but the gamecode also compiles
|
||||
/*
|
||||
typedef enum
|
||||
{
|
||||
SOLID_NOT, // no interaction with other objects
|
||||
SOLID_TRIGGER, // only touch when inside, after moving
|
||||
SOLID_BBOX, // touch on edge
|
||||
SOLID_BSP // bsp clip, touch on edge
|
||||
} solid_t;
|
||||
*/
|
||||
|
||||
//a trace is returned when a box is swept through the AAS world
|
||||
typedef struct aas_trace_s
|
||||
{
|
||||
qboolean startsolid; // if true, the initial point was in a solid area
|
||||
float fraction; // time completed, 1.0 = didn't hit anything
|
||||
vec3_t endpos; // final position
|
||||
int ent; // entity blocking the trace
|
||||
int lastarea; // last area the trace was in (zero if none)
|
||||
int area; // area blocking the trace (zero if none)
|
||||
int planenum; // number of the plane that was hit
|
||||
} aas_trace_t;
|
||||
|
||||
// Defined in botlib.h
|
||||
|
||||
//bsp_trace_t hit surface
|
||||
/*
|
||||
typedef struct bsp_surface_s
|
||||
{
|
||||
char name[16];
|
||||
int flags;
|
||||
int value;
|
||||
} bsp_surface_t;
|
||||
|
||||
//a trace is returned when a box is swept through the BSP world
|
||||
typedef struct bsp_trace_s
|
||||
{
|
||||
qboolean allsolid; // if true, plane is not valid
|
||||
qboolean startsolid; // if true, the initial point was in a solid area
|
||||
float fraction; // time completed, 1.0 = didn't hit anything
|
||||
vec3_t endpos; // final position
|
||||
cplane_t plane; // surface normal at impact
|
||||
float exp_dist; // expanded plane distance
|
||||
int sidenum; // number of the brush side hit
|
||||
bsp_surface_t surface; // hit surface
|
||||
int contents; // contents on other side of surface hit
|
||||
int ent; // number of entity hit
|
||||
} bsp_trace_t;
|
||||
*/
|
||||
//
|
||||
|
||||
|
||||
//entity info
|
||||
typedef struct aas_entityinfo_s
|
||||
{
|
||||
int valid; // true if updated this frame
|
||||
int type; // entity type
|
||||
int flags; // entity flags
|
||||
float ltime; // local time
|
||||
float update_time; // time between last and current update
|
||||
int number; // number of the entity
|
||||
vec3_t origin; // origin of the entity
|
||||
vec3_t angles; // angles of the model
|
||||
vec3_t old_origin; // for lerping
|
||||
vec3_t lastvisorigin; // last visible origin
|
||||
vec3_t mins; // bounding box minimums
|
||||
vec3_t maxs; // bounding box maximums
|
||||
int groundent; // ground entity
|
||||
int solid; // solid type
|
||||
int modelindex; // model used
|
||||
int modelindex2; // weapons, CTF flags, etc
|
||||
int frame; // model frame number
|
||||
int event; // impulse events -- muzzle flashes, footsteps, etc
|
||||
int eventParm; // even parameter
|
||||
int powerups; // bit flags
|
||||
int weapon; // determines weapon and flash model, etc
|
||||
int legsAnim; // mask off ANIM_TOGGLEBIT
|
||||
int torsoAnim; // mask off ANIM_TOGGLEBIT
|
||||
} aas_entityinfo_t;
|
||||
|
||||
// area info
|
||||
typedef struct aas_areainfo_s
|
||||
{
|
||||
int contents;
|
||||
int flags;
|
||||
int presencetype;
|
||||
int cluster;
|
||||
vec3_t mins;
|
||||
vec3_t maxs;
|
||||
vec3_t center;
|
||||
} aas_areainfo_t;
|
||||
|
||||
// client movement prediction stop events, stop as soon as:
|
||||
#define SE_NONE 0
|
||||
#define SE_HITGROUND 1 // the ground is hit
|
||||
#define SE_LEAVEGROUND 2 // there's no ground
|
||||
#define SE_ENTERWATER 4 // water is entered
|
||||
#define SE_ENTERSLIME 8 // slime is entered
|
||||
#define SE_ENTERLAVA 16 // lava is entered
|
||||
#define SE_HITGROUNDDAMAGE 32 // the ground is hit with damage
|
||||
#define SE_GAP 64 // there's a gap
|
||||
#define SE_TOUCHJUMPPAD 128 // touching a jump pad area
|
||||
#define SE_TOUCHTELEPORTER 256 // touching teleporter
|
||||
#define SE_ENTERAREA 512 // the given stoparea is entered
|
||||
#define SE_HITGROUNDAREA 1024 // a ground face in the area is hit
|
||||
#define SE_HITBOUNDINGBOX 2048 // hit the specified bounding box
|
||||
#define SE_TOUCHCLUSTERPORTAL 4096 // touching a cluster portal
|
||||
|
||||
typedef struct aas_clientmove_s
|
||||
{
|
||||
vec3_t endpos; //position at the end of movement prediction
|
||||
int endarea; //area at end of movement prediction
|
||||
vec3_t velocity; //velocity at the end of movement prediction
|
||||
aas_trace_t trace; //last trace
|
||||
int presencetype; //presence type at end of movement prediction
|
||||
int stopevent; //event that made the prediction stop
|
||||
int endcontents; //contents at the end of movement prediction
|
||||
float time; //time predicted ahead
|
||||
int frames; //number of frames predicted ahead
|
||||
} aas_clientmove_t;
|
||||
|
||||
// alternate route goals
|
||||
#define ALTROUTEGOAL_ALL 1
|
||||
#define ALTROUTEGOAL_CLUSTERPORTALS 2
|
||||
#define ALTROUTEGOAL_VIEWPORTALS 4
|
||||
|
||||
typedef struct aas_altroutegoal_s
|
||||
{
|
||||
vec3_t origin;
|
||||
int areanum;
|
||||
unsigned short starttraveltime;
|
||||
unsigned short goaltraveltime;
|
||||
unsigned short extratraveltime;
|
||||
} aas_altroutegoal_t;
|
||||
|
||||
// route prediction stop events
|
||||
#define RSE_NONE 0
|
||||
#define RSE_NOROUTE 1 //no route to goal
|
||||
#define RSE_USETRAVELTYPE 2 //stop as soon as on of the given travel types is used
|
||||
#define RSE_ENTERCONTENTS 4 //stop when entering the given contents
|
||||
#define RSE_ENTERAREA 8 //stop when entering the given area
|
||||
|
||||
typedef struct aas_predictroute_s
|
||||
{
|
||||
vec3_t endpos; //position at the end of movement prediction
|
||||
int endarea; //area at end of movement prediction
|
||||
int stopevent; //event that made the prediction stop
|
||||
int endcontents; //contents at the end of movement prediction
|
||||
int endtravelflags; //end travel flags
|
||||
int numareas; //number of areas predicted ahead
|
||||
int time; //time predicted ahead (in hundreth of a sec)
|
||||
} aas_predictroute_t;
|
|
@ -1,32 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_ai_char.h
|
||||
*
|
||||
* desc: bot characters
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_char.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 1 $
|
||||
* $Modtime: 5/17/02 11:35a $
|
||||
* $Date: 7/31/02 10:45a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//loads a bot character from a file
|
||||
int BotLoadCharacter(char *charfile, float skill);
|
||||
//frees a bot character
|
||||
void BotFreeCharacter(int character);
|
||||
//returns a float characteristic
|
||||
float Characteristic_Float(int character, int index);
|
||||
//returns a bounded float characteristic
|
||||
float Characteristic_BFloat(int character, int index, float min, float max);
|
||||
//returns an integer characteristic
|
||||
int Characteristic_Integer(int character, int index);
|
||||
//returns a bounded integer characteristic
|
||||
int Characteristic_BInteger(int character, int index, int min, int max);
|
||||
//returns a string characteristic
|
||||
void Characteristic_String(int character, int index, char *buf, int size);
|
||||
//free cached bot characters
|
||||
void BotShutdownCharacters(void);
|
|
@ -1,97 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
/*****************************************************************************
|
||||
* name: be_ai_chat.h
|
||||
*
|
||||
* desc: char AI
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_chat.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 1 $
|
||||
* $Modtime: 5/17/02 11:35a $
|
||||
* $Date: 7/31/02 10:45a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#define MAX_MESSAGE_SIZE 256
|
||||
#define MAX_CHATTYPE_NAME 32
|
||||
#define MAX_MATCHVARIABLES 8
|
||||
|
||||
#define CHAT_GENDERLESS 0
|
||||
#define CHAT_GENDERFEMALE 1
|
||||
#define CHAT_GENDERMALE 2
|
||||
|
||||
#define CHAT_ALL 0
|
||||
#define CHAT_TEAM 1
|
||||
#define CHAT_TELL 2
|
||||
|
||||
//a console message
|
||||
typedef struct bot_consolemessage_s
|
||||
{
|
||||
int handle;
|
||||
float time; //message time
|
||||
int type; //message type
|
||||
char message[MAX_MESSAGE_SIZE]; //message
|
||||
struct bot_consolemessage_s *prev, *next; //prev and next in list
|
||||
} bot_consolemessage_t;
|
||||
|
||||
//match variable
|
||||
typedef struct bot_matchvariable_s
|
||||
{
|
||||
char offset;
|
||||
int length;
|
||||
} bot_matchvariable_t;
|
||||
//returned to AI when a match is found
|
||||
typedef struct bot_match_s
|
||||
{
|
||||
char string[MAX_MESSAGE_SIZE];
|
||||
int type;
|
||||
int subtype;
|
||||
bot_matchvariable_t variables[MAX_MATCHVARIABLES];
|
||||
} bot_match_t;
|
||||
|
||||
//setup the chat AI
|
||||
int BotSetupChatAI(void);
|
||||
//shutdown the chat AI
|
||||
void BotShutdownChatAI(void);
|
||||
//returns the handle to a newly allocated chat state
|
||||
int BotAllocChatState(void);
|
||||
//frees the chatstate
|
||||
void BotFreeChatState(int handle);
|
||||
//adds a console message to the chat state
|
||||
void BotQueueConsoleMessage(int chatstate, int type, char *message);
|
||||
//removes the console message from the chat state
|
||||
void BotRemoveConsoleMessage(int chatstate, int handle);
|
||||
//returns the next console message from the state
|
||||
int BotNextConsoleMessage(int chatstate, bot_consolemessage_t *cm);
|
||||
//returns the number of console messages currently stored in the state
|
||||
int BotNumConsoleMessages(int chatstate);
|
||||
//selects a chat message of the given type
|
||||
void BotInitialChat(int chatstate, char *type, int mcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
|
||||
//returns the number of initial chat messages of the given type
|
||||
int BotNumInitialChats(int chatstate, char *type);
|
||||
//find and select a reply for the given message
|
||||
int BotReplyChat(int chatstate, char *message, int mcontext, int vcontext, char *var0, char *var1, char *var2, char *var3, char *var4, char *var5, char *var6, char *var7);
|
||||
//returns the length of the currently selected chat message
|
||||
int BotChatLength(int chatstate);
|
||||
//enters the selected chat message
|
||||
void BotEnterChat(int chatstate, int clientto, int sendto);
|
||||
//get the chat message ready to be output
|
||||
void BotGetChatMessage(int chatstate, char *buf, int size);
|
||||
//checks if the first string contains the second one, returns index into first string or -1 if not found
|
||||
int StringContains(char *str1, char *str2, int casesensitive);
|
||||
//finds a match for the given string using the match templates
|
||||
int BotFindMatch(char *str, bot_match_t *match, unsigned long int context);
|
||||
//returns a variable from a match
|
||||
void BotMatchVariable(bot_match_t *match, int variable, char *buf, int size);
|
||||
//unify all the white spaces in the string
|
||||
void UnifyWhiteSpaces(char *string);
|
||||
//replace all the context related synonyms in the string
|
||||
void BotReplaceSynonyms(char *string, unsigned long int context);
|
||||
//loads a chat file for the chat state
|
||||
int BotLoadChatFile(int chatstate, char *chatfile, char *chatname);
|
||||
//store the gender of the bot in the chat state
|
||||
void BotSetChatGender(int chatstate, int gender);
|
||||
//store the bot name in the chat state
|
||||
void BotSetChatName(int chatstate, char *name, int client);
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_ai_gen.h
|
||||
*
|
||||
* desc: genetic selection
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_gen.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 1 $
|
||||
* $Modtime: 5/17/02 11:35a $
|
||||
* $Date: 7/31/02 10:45a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
int GeneticParentsAndChildSelection(int numranks, float *ranks, int *parent1, int *parent2, int *child);
|
|
@ -1,102 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
/*****************************************************************************
|
||||
* name: be_ai_goal.h
|
||||
*
|
||||
* desc: goal AI
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_goal.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 1 $
|
||||
* $Modtime: 5/17/02 11:35a $
|
||||
* $Date: 7/31/02 10:45a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
#define MAX_AVOIDGOALS 256
|
||||
#define MAX_GOALSTACK 8
|
||||
|
||||
#define GFL_NONE 0
|
||||
#define GFL_ITEM 1
|
||||
#define GFL_ROAM 2
|
||||
#define GFL_DROPPED 4
|
||||
|
||||
//a bot goal
|
||||
typedef struct bot_goal_s
|
||||
{
|
||||
vec3_t origin; //origin of the goal
|
||||
int areanum; //area number of the goal
|
||||
vec3_t mins, maxs; //mins and maxs of the goal
|
||||
int entitynum; //number of the goal entity
|
||||
int number; //goal number
|
||||
int flags; //goal flags
|
||||
int iteminfo; //item information
|
||||
} bot_goal_t;
|
||||
|
||||
//reset the whole goal state, but keep the item weights
|
||||
void BotResetGoalState(int goalstate);
|
||||
//reset avoid goals
|
||||
void BotResetAvoidGoals(int goalstate);
|
||||
//remove the goal with the given number from the avoid goals
|
||||
void BotRemoveFromAvoidGoals(int goalstate, int number);
|
||||
//push a goal onto the goal stack
|
||||
void BotPushGoal(int goalstate, bot_goal_t *goal);
|
||||
//pop a goal from the goal stack
|
||||
void BotPopGoal(int goalstate);
|
||||
//empty the bot's goal stack
|
||||
void BotEmptyGoalStack(int goalstate);
|
||||
//dump the avoid goals
|
||||
void BotDumpAvoidGoals(int goalstate);
|
||||
//dump the goal stack
|
||||
void BotDumpGoalStack(int goalstate);
|
||||
//get the name name of the goal with the given number
|
||||
void BotGoalName(int number, char *name, int size);
|
||||
//get the top goal from the stack
|
||||
int BotGetTopGoal(int goalstate, bot_goal_t *goal);
|
||||
//get the second goal on the stack
|
||||
int BotGetSecondGoal(int goalstate, bot_goal_t *goal);
|
||||
//choose the best long term goal item for the bot
|
||||
int BotChooseLTGItem(int goalstate, vec3_t origin, int *inventory, int travelflags);
|
||||
//choose the best nearby goal item for the bot
|
||||
//the item may not be further away from the current bot position than maxtime
|
||||
//also the travel time from the nearby goal towards the long term goal may not
|
||||
//be larger than the travel time towards the long term goal from the current bot position
|
||||
int BotChooseNBGItem(int goalstate, vec3_t origin, int *inventory, int travelflags,
|
||||
bot_goal_t *ltg, float maxtime);
|
||||
//returns true if the bot touches the goal
|
||||
int BotTouchingGoal(vec3_t origin, bot_goal_t *goal);
|
||||
//returns true if the goal should be visible but isn't
|
||||
int BotItemGoalInVisButNotVisible(int viewer, vec3_t eye, vec3_t viewangles, bot_goal_t *goal);
|
||||
//search for a goal for the given classname, the index can be used
|
||||
//as a start point for the search when multiple goals are available with that same classname
|
||||
int BotGetLevelItemGoal(int index, char *classname, bot_goal_t *goal);
|
||||
//get the next camp spot in the map
|
||||
int BotGetNextCampSpotGoal(int num, bot_goal_t *goal);
|
||||
//get the map location with the given name
|
||||
int BotGetMapLocationGoal(char *name, bot_goal_t *goal);
|
||||
//returns the avoid goal time
|
||||
float BotAvoidGoalTime(int goalstate, int number);
|
||||
//set the avoid goal time
|
||||
void BotSetAvoidGoalTime(int goalstate, int number, float avoidtime);
|
||||
//initializes the items in the level
|
||||
void BotInitLevelItems(void);
|
||||
//regularly update dynamic entity items (dropped weapons, flags etc.)
|
||||
void BotUpdateEntityItems(void);
|
||||
//interbreed the goal fuzzy logic
|
||||
void BotInterbreedGoalFuzzyLogic(int parent1, int parent2, int child);
|
||||
//save the goal fuzzy logic to disk
|
||||
void BotSaveGoalFuzzyLogic(int goalstate, char *filename);
|
||||
//mutate the goal fuzzy logic
|
||||
void BotMutateGoalFuzzyLogic(int goalstate, float range);
|
||||
//loads item weights for the bot
|
||||
int BotLoadItemWeights(int goalstate, char *filename);
|
||||
//frees the item weights of the bot
|
||||
void BotFreeItemWeights(int goalstate);
|
||||
//returns the handle of a newly allocated goal state
|
||||
int BotAllocGoalState(int client);
|
||||
//free the given goal state
|
||||
void BotFreeGoalState(int handle);
|
||||
//setup the goal AI
|
||||
int BotSetupGoalAI(void);
|
||||
//shut down the goal AI
|
||||
void BotShutdownGoalAI(void);
|
|
@ -1,126 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_ai_move.h
|
||||
*
|
||||
* desc: movement AI
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_move.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 1 $
|
||||
* $Modtime: 5/17/02 11:35a $
|
||||
* $Date: 7/31/02 10:45a $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//movement types
|
||||
#define MOVE_WALK 1
|
||||
#define MOVE_CROUCH 2
|
||||
#define MOVE_JUMP 4
|
||||
#define MOVE_GRAPPLE 8
|
||||
#define MOVE_ROCKETJUMP 16
|
||||
#define MOVE_BFGJUMP 32
|
||||
//move flags
|
||||
#define MFL_BARRIERJUMP 1 //bot is performing a barrier jump
|
||||
#define MFL_ONGROUND 2 //bot is in the ground
|
||||
#define MFL_SWIMMING 4 //bot is swimming
|
||||
#define MFL_AGAINSTLADDER 8 //bot is against a ladder
|
||||
#define MFL_WATERJUMP 16 //bot is waterjumping
|
||||
#define MFL_TELEPORTED 32 //bot is being teleported
|
||||
#define MFL_GRAPPLEPULL 64 //bot is being pulled by the grapple
|
||||
#define MFL_ACTIVEGRAPPLE 128 //bot is using the grapple hook
|
||||
#define MFL_GRAPPLERESET 256 //bot has reset the grapple
|
||||
#define MFL_WALK 512 //bot should walk slowly
|
||||
// move result flags
|
||||
#define MOVERESULT_MOVEMENTVIEW 1 //bot uses view for movement
|
||||
#define MOVERESULT_SWIMVIEW 2 //bot uses view for swimming
|
||||
#define MOVERESULT_WAITING 4 //bot is waiting for something
|
||||
#define MOVERESULT_MOVEMENTVIEWSET 8 //bot has set the view in movement code
|
||||
#define MOVERESULT_MOVEMENTWEAPON 16 //bot uses weapon for movement
|
||||
#define MOVERESULT_ONTOPOFOBSTACLE 32 //bot is ontop of obstacle
|
||||
#define MOVERESULT_ONTOPOF_FUNCBOB 64 //bot is ontop of a func_bobbing
|
||||
#define MOVERESULT_ONTOPOF_ELEVATOR 128 //bot is ontop of an elevator (func_plat)
|
||||
#define MOVERESULT_BLOCKEDBYAVOIDSPOT 256 //bot is blocked by an avoid spot
|
||||
//
|
||||
#define MAX_AVOIDREACH 1
|
||||
#define MAX_AVOIDSPOTS 32
|
||||
// avoid spot types
|
||||
#define AVOID_CLEAR 0 //clear all avoid spots
|
||||
#define AVOID_ALWAYS 1 //avoid always
|
||||
#define AVOID_DONTBLOCK 2 //never totally block
|
||||
// restult types
|
||||
#define RESULTTYPE_ELEVATORUP 1 //elevator is up
|
||||
#define RESULTTYPE_WAITFORFUNCBOBBING 2 //waiting for func bobbing to arrive
|
||||
#define RESULTTYPE_BADGRAPPLEPATH 4 //grapple path is obstructed
|
||||
#define RESULTTYPE_INSOLIDAREA 8 //stuck in solid area, this is bad
|
||||
|
||||
//structure used to initialize the movement state
|
||||
//the or_moveflags MFL_ONGROUND, MFL_TELEPORTED and MFL_WATERJUMP come from the playerstate
|
||||
typedef struct bot_initmove_s
|
||||
{
|
||||
vec3_t origin; //origin of the bot
|
||||
vec3_t velocity; //velocity of the bot
|
||||
vec3_t viewoffset; //view offset
|
||||
int entitynum; //entity number of the bot
|
||||
int client; //client number of the bot
|
||||
float thinktime; //time the bot thinks
|
||||
int presencetype; //presencetype of the bot
|
||||
vec3_t viewangles; //view angles of the bot
|
||||
int or_moveflags; //values ored to the movement flags
|
||||
} bot_initmove_t;
|
||||
|
||||
//NOTE: the ideal_viewangles are only valid if MFL_MOVEMENTVIEW is set
|
||||
typedef struct bot_moveresult_s
|
||||
{
|
||||
int failure; //true if movement failed all together
|
||||
int type; //failure or blocked type
|
||||
int blocked; //true if blocked by an entity
|
||||
int blockentity; //entity blocking the bot
|
||||
int traveltype; //last executed travel type
|
||||
int flags; //result flags
|
||||
int weapon; //weapon used for movement
|
||||
vec3_t movedir; //movement direction
|
||||
vec3_t ideal_viewangles; //ideal viewangles for the movement
|
||||
} bot_moveresult_t;
|
||||
|
||||
// bk001204: from code/botlib/be_ai_move.c
|
||||
// TTimo 04/12/2001 was moved here to avoid dup defines
|
||||
typedef struct bot_avoidspot_s
|
||||
{
|
||||
vec3_t origin;
|
||||
float radius;
|
||||
int type;
|
||||
} bot_avoidspot_t;
|
||||
|
||||
//resets the whole move state
|
||||
void BotResetMoveState(int movestate);
|
||||
//moves the bot to the given goal
|
||||
void BotMoveToGoal(bot_moveresult_t *result, int movestate, bot_goal_t *goal, int travelflags);
|
||||
//moves the bot in the specified direction using the specified type of movement
|
||||
int BotMoveInDirection(int movestate, vec3_t dir, float speed, int type);
|
||||
//reset avoid reachability
|
||||
void BotResetAvoidReach(int movestate);
|
||||
//resets the last avoid reachability
|
||||
void BotResetLastAvoidReach(int movestate);
|
||||
//returns a reachability area if the origin is in one
|
||||
int BotReachabilityArea(vec3_t origin, int client);
|
||||
//view target based on movement
|
||||
int BotMovementViewTarget(int movestate, bot_goal_t *goal, int travelflags, float lookahead, vec3_t target);
|
||||
//predict the position of a player based on movement towards a goal
|
||||
int BotPredictVisiblePosition(vec3_t origin, int areanum, bot_goal_t *goal, int travelflags, vec3_t target);
|
||||
//returns the handle of a newly allocated movestate
|
||||
int BotAllocMoveState(void);
|
||||
//frees the movestate with the given handle
|
||||
void BotFreeMoveState(int handle);
|
||||
//initialize movement state before performing any movement
|
||||
void BotInitMoveState(int handle, bot_initmove_t *initmove);
|
||||
//add a spot to avoid (if type == AVOID_CLEAR all spots are removed)
|
||||
void BotAddAvoidSpot(int movestate, vec3_t origin, float radius, int type);
|
||||
//must be called every map change
|
||||
void BotSetBrushModelTypes(void);
|
||||
//setup movement AI
|
||||
int BotSetupMoveAI(void);
|
||||
//shutdown movement AI
|
||||
void BotShutdownMoveAI(void);
|
||||
|
|
@ -1,90 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_ai_weap.h
|
||||
*
|
||||
* desc: weapon AI
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ai_weap.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 4 $
|
||||
* $Modtime: 8/19/02 3:51p $
|
||||
* $Date: 8/19/02 4:08p $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//projectile flags
|
||||
#define PFL_WINDOWDAMAGE 1 //projectile damages through window
|
||||
#define PFL_RETURN 2 //set when projectile returns to owner
|
||||
//weapon flags
|
||||
#define WFL_FIRERELEASED 1 //set when projectile is fired with key-up event
|
||||
//damage types
|
||||
#define DAMAGETYPE_IMPACT 1 //damage on impact
|
||||
#define DAMAGETYPE_RADIAL 2 //radial damage
|
||||
#define DAMAGETYPE_VISIBLE 4 //damage to all entities visible to the projectile
|
||||
|
||||
typedef struct projectileinfo_s
|
||||
{
|
||||
char name[MAX_STRINGFIELD];
|
||||
char model[MAX_STRINGFIELD];
|
||||
int flags;
|
||||
float gravity;
|
||||
int damage;
|
||||
float radius;
|
||||
int visdamage;
|
||||
int damagetype;
|
||||
int healthinc;
|
||||
float push;
|
||||
float detonation;
|
||||
float bounce;
|
||||
float bouncefric;
|
||||
float bouncestop;
|
||||
} projectileinfo_t;
|
||||
|
||||
typedef struct weaponinfo_s
|
||||
{
|
||||
int valid; //true if the weapon info is valid
|
||||
int number; //number of the weapon
|
||||
char name[MAX_STRINGFIELD];
|
||||
char model[MAX_STRINGFIELD];
|
||||
int level;
|
||||
int weaponindex;
|
||||
int flags;
|
||||
char projectile[MAX_STRINGFIELD];
|
||||
int numprojectiles;
|
||||
float hspread;
|
||||
float vspread;
|
||||
float speed;
|
||||
float acceleration;
|
||||
vec3_t recoil;
|
||||
vec3_t offset;
|
||||
vec3_t angleoffset;
|
||||
float extrazvelocity;
|
||||
int ammoamount;
|
||||
int ammoindex;
|
||||
float activate;
|
||||
float reload;
|
||||
float spinup;
|
||||
float spindown;
|
||||
int primarydangerous; // if primary and/or alternate fire are REALLY DANGEROUS
|
||||
int altdangerous;
|
||||
projectileinfo_t proj; //pointer to the used projectile
|
||||
} weaponinfo_t;
|
||||
|
||||
//setup the weapon AI
|
||||
int BotSetupWeaponAI(void);
|
||||
//shut down the weapon AI
|
||||
void BotShutdownWeaponAI(void);
|
||||
//returns the best weapon to fight with
|
||||
int BotChooseBestFightWeapon(int weaponstate, int *inventory);
|
||||
//returns the information of the current weapon
|
||||
void BotGetWeaponInfo(int weaponstate, int weapon, weaponinfo_t *weaponinfo);
|
||||
//loads the weapon weights
|
||||
int BotLoadWeaponWeights(int weaponstate, char *filename);
|
||||
//returns a handle to a newly allocated weapon state
|
||||
int BotAllocWeaponState(void);
|
||||
//frees the weapon state
|
||||
void BotFreeWeaponState(int weaponstate);
|
||||
//resets the whole weapon state
|
||||
void BotResetWeaponState(int weaponstate);
|
|
@ -1,51 +0,0 @@
|
|||
// Copyright (C) 1999-2000 Id Software, Inc.
|
||||
//
|
||||
|
||||
/*****************************************************************************
|
||||
* name: be_ea.h
|
||||
*
|
||||
* desc: elementary actions
|
||||
*
|
||||
* $Archive: /Code/DLLs/game/be_ea.h $
|
||||
* $Author: Jwaters $
|
||||
* $Revision: 2 $
|
||||
* $Modtime: 8/08/02 12:17p $
|
||||
* $Date: 8/08/02 1:38p $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
//ClientCommand elementary actions
|
||||
void EA_Say(int client, char *str);
|
||||
void EA_SayTeam(int client, char *str);
|
||||
void EA_Command(int client, const char *command );
|
||||
|
||||
void EA_Action(int client, int action);
|
||||
void EA_Crouch(int client);
|
||||
void EA_Walk(int client);
|
||||
void EA_MoveUp(int client);
|
||||
void EA_MoveDown(int client);
|
||||
void EA_MoveForward(int client);
|
||||
void EA_MoveBack(int client);
|
||||
void EA_MoveLeft(int client);
|
||||
void EA_MoveRight(int client);
|
||||
void EA_ToggleFireState(int client);
|
||||
void EA_Attack(int client, int primarydangerous, int altdangerous);
|
||||
void EA_Respawn(int client);
|
||||
void EA_Talk(int client);
|
||||
void EA_Gesture(int client);
|
||||
void EA_Use(int client);
|
||||
|
||||
//regular elementary actions
|
||||
void EA_SelectWeapon(int client, int weapon);
|
||||
void EA_Jump(int client);
|
||||
void EA_DelayedJump(int client);
|
||||
void EA_Move(int client, vec3_t dir, float speed);
|
||||
void EA_View(int client, vec3_t viewangles);
|
||||
|
||||
//send regular input to the server
|
||||
void EA_EndRegular(int client, float thinktime);
|
||||
void EA_GetInput(int client, float thinktime, bot_input_t *input);
|
||||
void EA_ResetInput(int client);
|
||||
//setup and shutdown routines
|
||||
int EA_Setup(void);
|
||||
void EA_Shutdown(void);
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "beam.h"
|
||||
#include "../qcommon/qfiles.h"
|
||||
#include "game.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/*QUAKED func_beam (0 0.25 .5) (-8 -8 -8) (8 8 8) START_ON PERSIST WAVE NOISE
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "g_local.h"
|
||||
#include "BSpline.h"
|
||||
#include "game.h"
|
||||
|
||||
void BSpline::Set
|
||||
(
|
||||
|
|
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "entity.h"
|
||||
#include "bspline.h"
|
||||
#include "container.h"
|
||||
#include "level.h"
|
||||
|
||||
#define CAMERA_SWITCHTIME 0.5f
|
||||
|
||||
|
|
|
@ -1108,7 +1108,7 @@ void ScriptCompiler::EmitSwitch( sval_t val, unsigned int sourcePos )
|
|||
EmitOpcode( OP_SWITCH, sourcePos );
|
||||
|
||||
*reinterpret_cast< StateScript ** >( code_pos ) = stateScript;
|
||||
code_pos += sizeof( unsigned int );
|
||||
code_pos += sizeof(StateScript*);
|
||||
|
||||
bStartCanBreak = bCanBreak;
|
||||
iStartBreakJumpLocCount = iBreakJumpLocCount;
|
87
code/game/consoleevent.cpp
Normal file
87
code/game/consoleevent.cpp
Normal file
|
@ -0,0 +1,87 @@
|
|||
#include "consoleevent.h"
|
||||
#include "g_local.h"
|
||||
|
||||
//===============================
|
||||
// ConsoleEvent
|
||||
//===============================
|
||||
|
||||
MEM_BlockAlloc< ConsoleEvent, MEM_BLOCKSIZE > ConsoleEvent_allocator;
|
||||
|
||||
CLASS_DECLARATION(Event, ConsoleEvent, NULL)
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
/*
|
||||
=======================
|
||||
new ConsoleEvent
|
||||
=======================
|
||||
*/
|
||||
void* ConsoleEvent::operator new(size_t size)
|
||||
{
|
||||
return ConsoleEvent_allocator.Alloc();
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
delete ptr
|
||||
=======================
|
||||
*/
|
||||
void ConsoleEvent::operator delete(void* ptr)
|
||||
{
|
||||
ConsoleEvent_allocator.Free(ptr);
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
ConsoleEvent
|
||||
=======================
|
||||
*/
|
||||
ConsoleEvent::ConsoleEvent(void)
|
||||
{
|
||||
m_consoleedict = NULL;
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
SetConsoleEdict
|
||||
=======================
|
||||
*/
|
||||
void ConsoleEvent::SetConsoleEdict(gentity_t* edict)
|
||||
{
|
||||
m_consoleedict = edict;
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
GetConsoleEdict
|
||||
=======================
|
||||
*/
|
||||
gentity_t* ConsoleEvent::GetConsoleEdict(void)
|
||||
{
|
||||
if (m_consoleedict)
|
||||
return m_consoleedict;
|
||||
|
||||
return g_entities;
|
||||
}
|
||||
|
||||
/*
|
||||
=======================
|
||||
ErrorInternal
|
||||
=======================
|
||||
*/
|
||||
void ConsoleEvent::ErrorInternal(Listener* l, str text)
|
||||
{
|
||||
gentity_t* edict = GetConsoleEdict();
|
||||
str eventname = getName();
|
||||
|
||||
gi.DPrintf("^~^~^ Game ( Event '%s', Client '%s' ) : %s\n",
|
||||
eventname.c_str(),
|
||||
edict->client ? edict->client->pers.netname : "",
|
||||
text.c_str());
|
||||
|
||||
gi.SendServerCommand(GetConsoleEdict() - g_entities,
|
||||
"print \"Console: '%s' : %s\n\"",
|
||||
eventname.c_str(),
|
||||
text.c_str());
|
||||
}
|
27
code/game/consoleevent.h
Normal file
27
code/game/consoleevent.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#pragma once
|
||||
|
||||
#include <listener.h>
|
||||
#include <mem_blockalloc.h>
|
||||
#include "g_public.h"
|
||||
|
||||
class ConsoleEvent : public Event
|
||||
{
|
||||
private:
|
||||
gentity_t* m_consoleedict;
|
||||
|
||||
public:
|
||||
CLASS_PROTOTYPE(ConsoleEvent);
|
||||
|
||||
void* operator new(size_t size);
|
||||
void operator delete(void* ptr);
|
||||
|
||||
ConsoleEvent();
|
||||
ConsoleEvent(str name) : Event(name) { m_consoleedict = NULL; }
|
||||
|
||||
void SetConsoleEdict(gentity_t* edict);
|
||||
gentity_t* GetConsoleEdict(void);
|
||||
|
||||
virtual void ErrorInternal(Listener* l, str text);
|
||||
};
|
||||
|
||||
extern MEM_BlockAlloc< ConsoleEvent, MEM_BLOCKSIZE > ConsoleEvent_allocator;
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
//
|
||||
|
||||
#include "debuglines.h"
|
||||
#include "game.h"
|
||||
|
||||
#define NUM_CIRCLE_SEGMENTS 24
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
// decals.cpp: Decal entities
|
||||
|
||||
#include "decals.h"
|
||||
|
||||
#include "level.h"
|
||||
|
||||
CLASS_DECLARATION( Entity, Decal, NULL )
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "earthquake.h"
|
||||
#include "weapon.h"
|
||||
#include "sentient.h"
|
||||
#include "level.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/*QUAKED func_viewjitter (0 0.25 0.5) (-8 -8 -8) (8 8 8)
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "g_local.h"
|
||||
#include "entity.h"
|
||||
#include "game.h"
|
||||
|
||||
// FIXME: OLD Q3 CODE
|
||||
#if 0
|
||||
|
|
|
@ -1464,11 +1464,8 @@ GetGameAPI
|
|||
Gets game imports and returns game exports
|
||||
================
|
||||
*/
|
||||
#ifndef WIN32
|
||||
extern "C"
|
||||
__attribute__((visibility("default")))
|
||||
#endif
|
||||
gameExport_t* GetGameAPI( gameImport_t *import )
|
||||
gameExport_t * GetGameAPI(gameImport_t * import)
|
||||
{
|
||||
gi = *import;
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "g_local.h"
|
||||
#include "entity.h"
|
||||
#include "game.h"
|
||||
|
||||
typedef struct {
|
||||
qboolean validGroundTrace;
|
||||
|
|
|
@ -23,6 +23,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
// g_public.h -- game module information visible to server
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "bg_public.h"
|
||||
|
||||
#define GAME_API_VERSION 12
|
||||
|
||||
// entity->svFlags
|
||||
|
@ -807,6 +811,14 @@ typedef struct gameExport_s {
|
|||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
||||
#ifdef GAME_DLL
|
||||
#ifdef WIN32
|
||||
__declspec(dllexport)
|
||||
#else
|
||||
__attribute__((visibility("default")))
|
||||
#endif
|
||||
#endif
|
||||
gameExport_t* GetGameAPI( gameImport_t *import );
|
||||
|
||||
#if 0
|
||||
|
|
|
@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
*/
|
||||
//
|
||||
#include "g_local.h"
|
||||
#include "game.h"
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -26,12 +26,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "scriptmaster.h"
|
||||
#include "world.h"
|
||||
|
||||
#ifdef GAME_DLL
|
||||
#include "../game/camera.h"
|
||||
#include "../game/entity.h"
|
||||
#include "../game/player.h"
|
||||
#include "../game/dm_manager.h"
|
||||
#endif
|
||||
#include "camera.h"
|
||||
#include "entity.h"
|
||||
#include "player.h"
|
||||
#include "dm_manager.h"
|
||||
|
||||
Game game;
|
||||
|
||||
|
|
|
@ -22,12 +22,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
// game.h: General Game Info
|
||||
|
||||
#ifndef __GAME_H__
|
||||
#define __GAME_H__
|
||||
#pragma once
|
||||
|
||||
#include "glb_local.h"
|
||||
#include "listener.h"
|
||||
#include "level.h"
|
||||
#include "listener.h"
|
||||
#include "g_public.h"
|
||||
|
||||
class Game : public Listener
|
||||
{
|
||||
|
@ -46,6 +45,8 @@ public:
|
|||
~Game();
|
||||
};
|
||||
|
||||
class SimpleArchivedEntity;
|
||||
|
||||
/*
|
||||
* Functions prototypes
|
||||
*/
|
||||
|
@ -238,5 +239,3 @@ void G_TouchTriggers(
|
|||
);
|
||||
|
||||
extern Game game;
|
||||
|
||||
#endif /* __GAME_H__ */
|
||||
|
|
|
@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "player.h"
|
||||
#include <compiler.h>
|
||||
#include "playerbot.h"
|
||||
#include "consoleevent.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -26,6 +26,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "gamescript.h"
|
||||
#include "compiler.h"
|
||||
#include "scriptmaster.h"
|
||||
#include "level.h"
|
||||
|
||||
static unsigned char *current_progBuffer = NULL;
|
||||
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "gibs.h"
|
||||
#include "decals.h"
|
||||
#include "level.h"
|
||||
|
||||
Event EV_ThrowGib
|
||||
(
|
||||
|
|
|
@ -28,7 +28,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#define glbs gi
|
||||
|
||||
#include "g_local.h"
|
||||
#include <script.h>
|
||||
#include "qcommon.h"
|
||||
|
||||
#else
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "inventoryitem.h"
|
||||
#include "weaputils.h"
|
||||
#include "level.h"
|
||||
|
||||
Event EV_InventoryItem_Shoot
|
||||
(
|
||||
|
|
|
@ -30,6 +30,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "inventoryitem.h"
|
||||
#include "scriptmaster.h"
|
||||
#include "health.h"
|
||||
#include "game.h"
|
||||
|
||||
typedef struct {
|
||||
str name;
|
||||
|
|
|
@ -22,10 +22,10 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
// level.h: General Level Info
|
||||
|
||||
#ifndef __LEVEL_H__
|
||||
#define __LEVEL_H__
|
||||
#pragma once
|
||||
|
||||
#include "listener.h"
|
||||
#include "g_public.h"
|
||||
|
||||
#define MAX_HEAD_SENTIENTS 2
|
||||
#define MAX_EARTHQUAKES 10
|
||||
|
@ -290,5 +290,3 @@ qboolean Level::Reborn
|
|||
{
|
||||
return reborn;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "entity.h"
|
||||
#include "trigger.h"
|
||||
#include "mover.h"
|
||||
#include "level.h"
|
||||
|
||||
#define MOVE_ANGLES 1
|
||||
#define MOVE_ORIGIN 2
|
||||
|
|
|
@ -34,6 +34,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "stack.h"
|
||||
#include "container.h"
|
||||
#include "doors.h"
|
||||
#include "sentient.h"
|
||||
#include "../qcommon/qfiles.h"
|
||||
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "g_local.h"
|
||||
#include "actor.h"
|
||||
#include "playerbot.h"
|
||||
#include "consoleevent.h"
|
||||
|
||||
// We assume that we have limited access to the server-side
|
||||
// and that most logic come from the playerstate_s structure
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
// portal.cpp: Portals - surfaces that are mirrors or cameras
|
||||
|
||||
#include "portal.h"
|
||||
#include "game.h"
|
||||
|
||||
/*QUAKED portal_surface (1 0 1) (-8 -8 -8) (8 8 8)
|
||||
The portal surface nearest this entity will show a view from the targeted portal_camera, or a mirror view if untargeted.
|
||||
|
|
|
@ -59,6 +59,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "../game/huddraw.h"
|
||||
#include "../game/weaputils.h"
|
||||
#include "../game/camera.h"
|
||||
#include "../game/consoleevent.h"
|
||||
|
||||
#define SCRIPT_Printf gi.Printf
|
||||
#define SCRIPT_DPrintf gi.DPrintf
|
||||
|
@ -2162,88 +2163,6 @@ Event EV_ScriptThread_CancelWaiting
|
|||
"internal event"
|
||||
);
|
||||
|
||||
con_timer::con_timer( void )
|
||||
{
|
||||
m_inttime = 0;
|
||||
m_bDirty = false;
|
||||
}
|
||||
|
||||
void con_timer::AddElement( Class *e, int inttime )
|
||||
{
|
||||
Element element;
|
||||
|
||||
element.obj = e;
|
||||
element.inttime = inttime;
|
||||
|
||||
m_Elements.AddObject( element );
|
||||
|
||||
if( inttime <= m_inttime ) {
|
||||
SetDirty();
|
||||
}
|
||||
}
|
||||
|
||||
void con_timer::RemoveElement( Class *e )
|
||||
{
|
||||
for( int i = m_Elements.NumObjects(); i > 0; i-- )
|
||||
{
|
||||
Element *index = &m_Elements.ObjectAt( i );
|
||||
|
||||
if( index->obj == e )
|
||||
{
|
||||
m_Elements.RemoveObjectAt( i );
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Class *con_timer::GetNextElement( int& foundtime )
|
||||
{
|
||||
int best_inttime;
|
||||
int i;
|
||||
int foundIndex;
|
||||
Class *result;
|
||||
|
||||
foundIndex = 0;
|
||||
best_inttime = m_inttime;
|
||||
|
||||
for( i = m_Elements.NumObjects(); i > 0; i-- )
|
||||
{
|
||||
if( m_Elements.ObjectAt( i ).inttime <= best_inttime )
|
||||
{
|
||||
best_inttime = m_Elements.ObjectAt( i ).inttime;
|
||||
foundIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if( foundIndex )
|
||||
{
|
||||
result = m_Elements.ObjectAt( foundIndex ).obj;
|
||||
m_Elements.RemoveObjectAt( foundIndex );
|
||||
foundtime = best_inttime;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = NULL;
|
||||
m_bDirty = false;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void con_timer::ArchiveElement( Archiver& arc, Element *e )
|
||||
{
|
||||
arc.ArchiveObjectPointer( &e->obj );
|
||||
arc.ArchiveInteger( &e->inttime );
|
||||
}
|
||||
|
||||
void con_timer::Archive( Archiver& arc )
|
||||
{
|
||||
arc.ArchiveBool( &m_bDirty );
|
||||
arc.ArchiveInteger( &m_inttime );
|
||||
|
||||
m_Elements.Archive( arc, con_timer::ArchiveElement );
|
||||
}
|
||||
|
||||
void ScriptMaster::Archive( Archiver& arc )
|
||||
{
|
||||
ScriptClass *scr;
|
|
@ -28,6 +28,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "class.h"
|
||||
#include "listener.h"
|
||||
#include "scriptvm.h"
|
||||
#include <con_timer.h>
|
||||
|
||||
#define MAX_COMMANDS 20
|
||||
#define MAX_EXECUTION_TIME 3000
|
||||
|
@ -35,37 +36,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
void Showmenu( str name, qboolean bForce );
|
||||
void Hidemenu( str name, qboolean bForce );
|
||||
|
||||
class con_timer : public Class
|
||||
{
|
||||
public:
|
||||
class Element
|
||||
{
|
||||
public:
|
||||
Class *obj;
|
||||
int inttime;
|
||||
};
|
||||
|
||||
private:
|
||||
Container< con_timer::Element > m_Elements;
|
||||
bool m_bDirty;
|
||||
int m_inttime;
|
||||
|
||||
public:
|
||||
con_timer();
|
||||
|
||||
void AddElement( Class *e, int inttime );
|
||||
void RemoveElement( Class *e );
|
||||
|
||||
Class *GetNextElement( int& foundTime );
|
||||
|
||||
void SetDirty( void ) { m_bDirty = true; };
|
||||
bool IsDirty( void ) { return m_bDirty; };
|
||||
void SetTime( int inttime ) { m_inttime = inttime; };
|
||||
|
||||
static void ArchiveElement( Archiver& arc, Element *e );
|
||||
virtual void Archive( Archiver& arc );
|
||||
};
|
||||
|
||||
#define MAX_VAR_STACK 1024
|
||||
#define MAX_FASTEVENT 10
|
||||
|
|
@ -38,6 +38,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "weapon.h"
|
||||
#include "gibs.h"
|
||||
#include "explosion.h"
|
||||
#include "game.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/*QUAKED script_object (0 0.5 1) ? NOT_SOLID
|
||||
|
|
|
@ -23,10 +23,12 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
// scripttimer.cpp: Scripted Timer & Fader
|
||||
//
|
||||
|
||||
#include "glb_local.h"
|
||||
#include "scripttimer.h"
|
||||
#include "ScriptTimer.h"
|
||||
#include "level.h"
|
||||
|
||||
#if defined(GAME_DLL)
|
||||
#include "archive.h"
|
||||
#endif
|
||||
|
||||
Event EV_ScriptTimer_Think
|
||||
(
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
===========================================================================
|
||||
*/
|
||||
|
||||
// scripttimer.cpp: Scripted Timer & Fader
|
||||
// ScriptTimer.cpp: Scripted Timer & Fader
|
||||
//
|
||||
|
||||
#ifndef __SCRIPTTIMER_H__
|
||||
|
@ -53,9 +53,11 @@ public:
|
|||
CLASS_PROTOTYPE( ScriptTimer );
|
||||
|
||||
ScriptTimer( timertype_e type = TIMER_NORMAL );
|
||||
virtual ~ScriptTimer();
|
||||
~ScriptTimer();
|
||||
|
||||
virtual void Archive( Archiver &arc );
|
||||
#if defined(ARCHIVE_SUPPORTED)
|
||||
void Archive( Archiver &arc ) override;
|
||||
#endif
|
||||
|
||||
void Think( Event *ev );
|
||||
|
2353
code/game/scriptvm.cpp
Normal file
2353
code/game/scriptvm.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -114,7 +114,6 @@ inline ActiveWeapon::ActiveWeapon
|
|||
)
|
||||
|
||||
{
|
||||
weapon = NULL;
|
||||
hand = WEAPON_ERROR;
|
||||
}
|
||||
|
||||
|
@ -394,7 +393,7 @@ inline void Sentient::ClearNewActiveWeapon
|
|||
)
|
||||
|
||||
{
|
||||
newActiveWeapon.weapon = NULL;
|
||||
newActiveWeapon.weapon.Clear();
|
||||
newActiveWeapon.hand = WEAPON_ERROR;
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "glb_local.h"
|
||||
#include "simpleentity.h"
|
||||
#include "world.h"
|
||||
#include "level.h"
|
||||
|
||||
Event EV_SimpleEntity_GetAngle
|
||||
(
|
|
@ -33,6 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
******************************************************************************/
|
||||
|
||||
#include "spawners.h"
|
||||
#include "game.h"
|
||||
|
||||
Event EV_Spawn_ModelName
|
||||
(
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "g_local.h"
|
||||
#include "specialfx.h"
|
||||
#include "level.h"
|
||||
|
||||
/*****************************************************************************/
|
||||
/*QUAKED func_fulcrum (0 0 1) ? X_AXIS_ONLY Y_AXIS_ONLY
|
||||
|
|
|
@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "animate.h"
|
||||
#include "viewthing.h"
|
||||
#include "game.h"
|
||||
#include "level.h"
|
||||
|
||||
Event EV_ViewThing_Think
|
||||
(
|
||||
|
|
|
@ -39,6 +39,7 @@ extern Event EV_Projectile_Explode;
|
|||
extern Event EV_Projectile_UpdateBeam;
|
||||
|
||||
class Weapon;
|
||||
class Sentient;
|
||||
|
||||
class Projectile : public Animate
|
||||
{
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
//
|
||||
|
||||
#include "windows.h"
|
||||
#include "game.h"
|
||||
|
||||
Event EV_Window_Setup
|
||||
(
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
// world.cpp : Holds the target list, and general info (fog and such).
|
||||
|
||||
#include "world.h"
|
||||
#include "level.h"
|
||||
#include <scriptmaster.h>
|
||||
|
||||
#ifdef GAME_DLL
|
|
@ -1,381 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// archive.cpp: OpenMoHAA Archiver
|
||||
|
||||
#include "glb_local.h"
|
||||
#include "archive.h"
|
||||
#include <lz77.h>
|
||||
|
||||
#ifdef GAME_DLL
|
||||
#include "../game/entity.h"
|
||||
#endif
|
||||
|
||||
|
||||
CLASS_DECLARATION( Class, FileRead, NULL )
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
FileRead::FileRead()
|
||||
{
|
||||
}
|
||||
|
||||
FileRead::~FileRead()
|
||||
{
|
||||
}
|
||||
|
||||
void FileRead::Close
|
||||
(
|
||||
bool bDoCompression
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
const char *FileRead::Filename
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
size_t FileRead::Length
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return length;
|
||||
}
|
||||
|
||||
size_t FileRead::Pos
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
qboolean FileRead::Seek
|
||||
(
|
||||
size_t newpos
|
||||
)
|
||||
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean FileRead::Open
|
||||
(
|
||||
const char *name
|
||||
)
|
||||
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean FileRead::Read
|
||||
(
|
||||
void *dest,
|
||||
size_t size
|
||||
)
|
||||
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
CLASS_DECLARATION( Class, Archiver, NULL )
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
Archiver::Archiver()
|
||||
{
|
||||
}
|
||||
|
||||
Archiver::~Archiver()
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::FileError
|
||||
(
|
||||
const char *fmt,
|
||||
...
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::Close
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
File Read/Write functions
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
qboolean Archiver::Read
|
||||
(
|
||||
const char *name,
|
||||
qboolean harderror
|
||||
)
|
||||
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
qboolean Archiver::Create
|
||||
(
|
||||
const char *name,
|
||||
qboolean harderror
|
||||
)
|
||||
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
|
||||
inline void Archiver::CheckRead
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline void Archiver::CheckWrite
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline size_t Archiver::ReadSize
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline void Archiver::CheckSize
|
||||
(
|
||||
int type,
|
||||
size_t size
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline void Archiver::WriteSize
|
||||
(
|
||||
size_t size
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline int Archiver::ReadType
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
inline void Archiver::WriteType
|
||||
(
|
||||
int type
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
inline void Archiver::CheckType
|
||||
(
|
||||
int type
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
/****************************************************************************************
|
||||
|
||||
File Archive functions
|
||||
|
||||
*****************************************************************************************/
|
||||
|
||||
//#define ARCHIVE_USE_TYPES 1
|
||||
|
||||
inline void Archiver::ArchiveData
|
||||
(
|
||||
int type,
|
||||
void *data,
|
||||
size_t size
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
#define ARCHIVE( func, type ) \
|
||||
void Archiver::Archive##func \
|
||||
( \
|
||||
type * v \
|
||||
) \
|
||||
\
|
||||
{ \
|
||||
}
|
||||
|
||||
ARCHIVE( Vector, Vector );
|
||||
ARCHIVE( Integer, int );
|
||||
ARCHIVE( Unsigned, unsigned );
|
||||
ARCHIVE( Size, size_t );
|
||||
ARCHIVE( Byte, byte );
|
||||
ARCHIVE( Char, char );
|
||||
ARCHIVE( Short, short );
|
||||
ARCHIVE( UnsignedShort, unsigned short );
|
||||
ARCHIVE( Float, float );
|
||||
ARCHIVE( Double, double );
|
||||
ARCHIVE( Boolean, qboolean );
|
||||
ARCHIVE( Quat, Quat );
|
||||
ARCHIVE( Bool, bool );
|
||||
ARCHIVE( Position, int );
|
||||
|
||||
void Archiver::ArchiveSvsTime
|
||||
(
|
||||
int *time
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveVec2
|
||||
(
|
||||
vec2_t vec
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveVec3
|
||||
(
|
||||
vec3_t vec
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveVec4
|
||||
(
|
||||
vec4_t vec
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveObjectPointer
|
||||
(
|
||||
Class ** ptr
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveObjectPosition( void *obj )
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveSafePointer
|
||||
(
|
||||
SafePtrBase * ptr
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveEventPointer
|
||||
(
|
||||
Event ** ev
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveRaw
|
||||
(
|
||||
void *data,
|
||||
size_t size
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveString
|
||||
(
|
||||
str * string
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
void Archiver::ArchiveConfigString( int cs )
|
||||
{
|
||||
}
|
||||
|
||||
Class * Archiver::ReadObject
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void Archiver::ArchiveObject
|
||||
(
|
||||
Class *obj
|
||||
)
|
||||
|
||||
{
|
||||
}
|
||||
|
||||
qboolean Archiver::ObjectPositionExists( void *obj )
|
||||
{
|
||||
return qfalse;
|
||||
}
|
||||
|
||||
void Archiver::SetSilent( bool bSilent )
|
||||
{
|
||||
}
|
|
@ -1,165 +0,0 @@
|
|||
#include <glb_local.h>
|
||||
#include <scriptmaster.h>
|
||||
#include <baseimp.h>
|
||||
#include <dummy_base.h>
|
||||
#include <world.h>
|
||||
#include <g_spawn.h>
|
||||
#include <Windows.h>
|
||||
|
||||
void BaseInit( void )
|
||||
{
|
||||
developer = new cvar_t;
|
||||
g_scriptcheck = new cvar_t;
|
||||
g_showopcodes = new cvar_t;
|
||||
precache = new cvar_t;
|
||||
sv_scriptfiles = new cvar_t;
|
||||
|
||||
memset( developer, 0, sizeof( cvar_t ) );
|
||||
memset( g_scriptcheck, 0, sizeof( cvar_t ) );
|
||||
memset( g_showopcodes, 0, sizeof( cvar_t ) );
|
||||
memset( precache, 0, sizeof( cvar_t ) );
|
||||
memset( sv_scriptfiles, 0, sizeof( cvar_t ) );
|
||||
|
||||
Com_FillBaseImports();
|
||||
|
||||
Swap_Init();
|
||||
Z_InitMemory();
|
||||
|
||||
Cmd_Init();
|
||||
Cvar_Init();
|
||||
|
||||
FS_InitFilesystem2();
|
||||
|
||||
L_InitEvents();
|
||||
|
||||
#ifndef NO_SCRIPTENGINE
|
||||
level.m_LoopProtection = false;
|
||||
world = new World;
|
||||
|
||||
Director.Init();
|
||||
Director.Reset( false );
|
||||
|
||||
Director.maxTime = 50;
|
||||
#endif
|
||||
}
|
||||
|
||||
void BaseRunFrame( double frametime )
|
||||
{
|
||||
level.setFrametime( frametime );
|
||||
level.setTime( clock() );
|
||||
|
||||
#ifndef NO_SCRIPTENGINE
|
||||
Director.SetTime( level.inttime );
|
||||
Director.m_bAllowContextSwitch = true;
|
||||
#endif
|
||||
|
||||
L_ProcessPendingEvents();
|
||||
#ifndef NO_SCRIPTENGINE
|
||||
Director.ExecuteRunning();
|
||||
#endif
|
||||
}
|
||||
|
||||
void BaseIdle( void )
|
||||
{
|
||||
double frametime = 0;
|
||||
double lastframetime;
|
||||
double tick = 0;
|
||||
|
||||
bi.Printf( "BaseIdle()\n" );
|
||||
|
||||
tick = ( double )clock();// / 1000.0;
|
||||
lastframetime = tick;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
tick = ( double )clock();// / 1000.0;
|
||||
|
||||
frametime = ( tick - lastframetime );
|
||||
lastframetime = tick;
|
||||
|
||||
BaseRunFrame( frametime );
|
||||
|
||||
Sleep( 50 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef _WINDLL
|
||||
void InitModule();
|
||||
void ShutdownModule();
|
||||
|
||||
BOOL APIENTRY DllMain(HMODULE hModule,
|
||||
DWORD ul_reason_for_call,
|
||||
LPVOID lpReserved
|
||||
)
|
||||
{
|
||||
switch (ul_reason_for_call)
|
||||
{
|
||||
case DLL_PROCESS_ATTACH:
|
||||
BaseInit();
|
||||
InitModule();
|
||||
break;
|
||||
case DLL_PROCESS_DETACH:
|
||||
ShutdownModule();
|
||||
|
||||
L_ShutdownEvents();
|
||||
|
||||
Com_Shutdown();
|
||||
FS_Shutdown(qtrue);
|
||||
break;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
|
||||
int MainEvent(const Container< Event * >& conev);
|
||||
|
||||
int main( int argc, char **argv )
|
||||
{
|
||||
Container< Event * > conev;
|
||||
Event *ev;
|
||||
int i;
|
||||
char *arg;
|
||||
|
||||
BaseInit();
|
||||
|
||||
// copy the argument list
|
||||
for( i = 0; i < argc; i++ )
|
||||
{
|
||||
arg = argv[ i ];
|
||||
|
||||
if( strlen( arg ) <= 1 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if( *arg != '/' && *arg != '-' && *arg != '+' ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ev = new Event( arg + 1 );
|
||||
|
||||
for( i++; i < argc; i++ )
|
||||
{
|
||||
arg = argv[ i ];
|
||||
if( *arg == '/' || *arg == '-' || *arg == '+' ) {
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
|
||||
ev->AddString( argv[ i ] );
|
||||
}
|
||||
|
||||
conev.AddObject( ev );
|
||||
}
|
||||
|
||||
MainEvent( conev );
|
||||
|
||||
conev.FreeObjectList();
|
||||
|
||||
L_ShutdownEvents();
|
||||
|
||||
Com_Shutdown();
|
||||
FS_Shutdown( qtrue );
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,4 +0,0 @@
|
|||
#include "listener.h"
|
||||
|
||||
void BaseRunFrame( double frametime );
|
||||
void BaseIdle( void );
|
|
@ -1,273 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// console.h: TU Console.
|
||||
|
||||
#include "console.h"
|
||||
#include <Windows.h>
|
||||
|
||||
CLASS_DECLARATION( Listener, ConsoleInput, NULL )
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
HANDLE WINAPI WIN_CreateThread
|
||||
(
|
||||
LPSECURITY_ATTRIBUTES lpThreadAttributes,
|
||||
SIZE_T dwStackSize,
|
||||
LPTHREAD_START_ROUTINE lpStartAddress,
|
||||
LPVOID lpParameter,
|
||||
DWORD dwCreationFlags,
|
||||
LPDWORD lpThreadId
|
||||
)
|
||||
|
||||
{
|
||||
return CreateThread( lpThreadAttributes, dwStackSize, lpStartAddress, lpParameter, dwCreationFlags, lpThreadId );
|
||||
}
|
||||
|
||||
|
||||
DWORD WINAPI InputThread
|
||||
(
|
||||
LPVOID lpParameter
|
||||
)
|
||||
|
||||
{
|
||||
ConsoleInput *console = ( ConsoleInput * )lpParameter;
|
||||
console->Input_Idle();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
void *InputThread
|
||||
(
|
||||
void *arg
|
||||
)
|
||||
|
||||
{
|
||||
ConsoleInput *console = ( ConsoleInput * )lpParameter;
|
||||
console->Input_Idle();
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
ConsoleInput::ConsoleInput()
|
||||
{
|
||||
}
|
||||
|
||||
ConsoleInput::ConsoleInput( Listener *consoleEvent )
|
||||
{
|
||||
m_pConsoleEvent = consoleEvent;
|
||||
}
|
||||
|
||||
void ConsoleInput::InitInput( void )
|
||||
{
|
||||
#ifdef WIN32
|
||||
WIN_CreateThread( NULL, 0, InputThread, ( void * )this, 0, NULL );
|
||||
#else
|
||||
pthread_t thread;
|
||||
|
||||
pthread_create( &thread, NULL, ( void * ( *)( void * ) )&InputThread, ( void * )this );
|
||||
#endif
|
||||
}
|
||||
|
||||
bool ConsoleInput::CheckEvent
|
||||
(
|
||||
Event *ev
|
||||
)
|
||||
|
||||
{
|
||||
EventDef *def = m_pConsoleEvent->classinfo()->GetDef( ev->eventnum );
|
||||
|
||||
if( !def )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if( !( def->flags & EV_CONSOLE ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ConsoleInput::PrintHelp
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
ResponseDef< Class > *r;
|
||||
|
||||
bi.Printf( "Command list :\n\n" );
|
||||
|
||||
r = m_pConsoleEvent->classinfo()->responses;
|
||||
while( r->event )
|
||||
{
|
||||
r->def->PrintEventDocumentation( stdout, false );
|
||||
r++;
|
||||
}
|
||||
}
|
||||
|
||||
bool ConsoleInput::Execute
|
||||
(
|
||||
const char *data
|
||||
)
|
||||
|
||||
{
|
||||
char *buffer;
|
||||
const char *com_token;
|
||||
str sCommand;
|
||||
|
||||
buffer = ( char * )malloc( strlen( data ) + 1 );
|
||||
strcpy( buffer, data );
|
||||
|
||||
com_token = COM_Parse( &buffer );
|
||||
|
||||
if( !com_token )
|
||||
{
|
||||
Com_Printf( "Enter a valid command.\n" );
|
||||
free( buffer );
|
||||
return false;
|
||||
}
|
||||
|
||||
sCommand = com_token;
|
||||
|
||||
if( Event::FindEventNum( sCommand ) )
|
||||
{
|
||||
Event *ev = new Event( sCommand );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
com_token = COM_Parse( &buffer );
|
||||
|
||||
if( !com_token[ 0 ] )
|
||||
break;
|
||||
|
||||
ev->AddString( com_token );
|
||||
}
|
||||
|
||||
if( CheckEvent( ev ) )
|
||||
{
|
||||
m_pConsoleEvent->ProcessEvent( ev );
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf( "Command '%s' not available from console.\n", sCommand.c_str() );
|
||||
free( buffer );
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Com_Printf( "Command '%s' is not valid. Type help for more info.\n", sCommand.c_str() );
|
||||
free( buffer );
|
||||
return false;
|
||||
}
|
||||
|
||||
free( buffer );
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ConsoleInput::Execute
|
||||
(
|
||||
int argc,
|
||||
char *argv[]
|
||||
)
|
||||
|
||||
{
|
||||
size_t iLength = 0;
|
||||
int i;
|
||||
char *data;
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
iLength += strlen( argv[ i ] ) + 1;
|
||||
}
|
||||
|
||||
if( iLength <= 1 )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
data = ( char * )malloc( iLength + 1 );
|
||||
|
||||
memset( data, 0, iLength + 1 );
|
||||
|
||||
for( i = 1; i < argc; i++ )
|
||||
{
|
||||
strcat( data, argv[ i ] );
|
||||
strcat( data, " " );
|
||||
}
|
||||
|
||||
bool bResult = Execute( data );
|
||||
free( data );
|
||||
|
||||
return bResult;
|
||||
}
|
||||
|
||||
void ConsoleInput::Input_Idle
|
||||
(
|
||||
void
|
||||
)
|
||||
|
||||
{
|
||||
char *szBuffer = ( char * )malloc( 255 );
|
||||
int i;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
i = 0;
|
||||
|
||||
/*while( !feof( stdin ) )
|
||||
{
|
||||
szBuffer[ i ] = getchar();
|
||||
|
||||
if( szBuffer[ i ] == '\r' || szBuffer[ i ] == '\n' )
|
||||
{
|
||||
szBuffer[ i ] = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if( szBuffer[ i ] == '\b' )
|
||||
{
|
||||
szBuffer[ i ] = 0;
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
fgets( szBuffer, 255, stdin );
|
||||
OemToCharBuff( szBuffer, szBuffer, 255 );
|
||||
|
||||
Execute( szBuffer );
|
||||
}
|
||||
}
|
|
@ -1,52 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// console.h: Console.
|
||||
|
||||
#ifndef __CONSOLE_H__
|
||||
#define __CONSOLE_H__
|
||||
|
||||
#include <listener.h>
|
||||
|
||||
class ConsoleInput : public Listener {
|
||||
private:
|
||||
Listener *m_pConsoleEvent;
|
||||
|
||||
public:
|
||||
void Input_Idle( void );
|
||||
|
||||
public:
|
||||
CLASS_PROTOTYPE( ConsoleInput );
|
||||
|
||||
ConsoleInput();
|
||||
ConsoleInput( Listener *consoleEvent );
|
||||
|
||||
void InitInput( void );
|
||||
|
||||
bool Execute( const char *data );
|
||||
bool Execute( int argc, char *argv[] );
|
||||
|
||||
bool CheckEvent( Event *ev );
|
||||
void PrintHelp( void );
|
||||
};
|
||||
|
||||
#endif /* __CONSOLE_H__ */
|
|
@ -1,268 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include <q_shared.h>
|
||||
#include <baseimp.h>
|
||||
#include <str.h>
|
||||
#include "dummy_base.h"
|
||||
#include "../client/client.h"
|
||||
#include <Windows.h>
|
||||
|
||||
clientStatic_t cls;
|
||||
baseImport_t bi;
|
||||
|
||||
cvar_t *developer;
|
||||
cvar_t *g_scriptcheck;
|
||||
cvar_t *g_showopcodes;
|
||||
cvar_t *precache;
|
||||
cvar_t *sv_scriptfiles;
|
||||
|
||||
void Com_FillBaseImports() {
|
||||
bi.Printf = BI_Printf;
|
||||
bi.DPrintf = BI_DPrintf;
|
||||
bi.Error = BI_Error;
|
||||
bi.Free = BI_Free;
|
||||
bi.Malloc = BI_Malloc;
|
||||
|
||||
bi.Milliseconds = BI_Milliseconds;
|
||||
|
||||
bi.FS_FreeFile = FS_FreeFile;
|
||||
bi.FS_ReadFile = FS_ReadFile2;
|
||||
bi.FS_CanonicalFilename = FS_CanonicalFilename;
|
||||
}
|
||||
|
||||
void Z_InitMemory() {
|
||||
}
|
||||
|
||||
void Cmd_Init( void ) {
|
||||
}
|
||||
|
||||
void Cvar_Init( void ) {
|
||||
}
|
||||
|
||||
void FS_InitFilesystem( void ) {
|
||||
}
|
||||
|
||||
void FS_InitFilesystem2( void ) {
|
||||
}
|
||||
|
||||
void QDECL Com_Error( int level, const char *error, ... ) {
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
va_start( argptr, error );
|
||||
size = vsnprintf( NULL, 0, error, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, error );
|
||||
vsnprintf( buffer, size, error, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
bi.Error( level, "%s", buffer );
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
void QDECL Com_Printf( const char *msg, ... ) {
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
va_start( argptr, msg );
|
||||
size = vsnprintf( NULL, 0, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, msg );
|
||||
vsnprintf( buffer, size, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
bi.Printf( "%s", buffer );
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
void QDECL Com_DPrintf( const char *msg, ... ) {
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
va_start( argptr, msg );
|
||||
size = vsnprintf( NULL, 0, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, msg );
|
||||
vsnprintf( buffer, size, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
bi.DPrintf( "%s", buffer );
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
void BI_Printf( const char *msg, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
va_start( argptr, msg );
|
||||
size = vsnprintf( NULL, 0, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, msg );
|
||||
vsnprintf( buffer, size, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
printf( "%s", buffer );
|
||||
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
void BI_DPrintf( const char *msg, ... )
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
if( !developer->integer ) {
|
||||
return;
|
||||
}
|
||||
|
||||
va_start( argptr, msg );
|
||||
size = vsnprintf( NULL, 0, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, msg );
|
||||
vsnprintf( buffer, size, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
printf( "%s", buffer );
|
||||
|
||||
bi.Free( buffer );
|
||||
#endif
|
||||
}
|
||||
|
||||
void BI_Error( int level, const char *msg, ... )
|
||||
{
|
||||
va_list argptr;
|
||||
char *buffer;
|
||||
int size;
|
||||
|
||||
va_start( argptr, msg );
|
||||
size = vsnprintf( NULL, 0, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
buffer = ( char * )bi.Malloc( size + 1 );
|
||||
buffer[ size ] = 0;
|
||||
|
||||
va_start( argptr, msg );
|
||||
vsnprintf( buffer, size, msg, argptr );
|
||||
va_end( argptr );
|
||||
|
||||
BI_Printf( "%s", buffer );
|
||||
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
int BI_Milliseconds( void )
|
||||
{
|
||||
return GetTickCount();
|
||||
}
|
||||
|
||||
void *BI_Malloc( int size )
|
||||
{
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
void BI_Free( void *ptr )
|
||||
{
|
||||
free( ptr );
|
||||
}
|
||||
|
||||
void FS_FreeFile( void *buffer )
|
||||
{
|
||||
bi.Free( buffer );
|
||||
}
|
||||
|
||||
int FS_ReadFile2( const char *name, void **buffer, qboolean bSilent )
|
||||
{
|
||||
str filename = name;
|
||||
FILE *file = fopen( filename, "rb+" );
|
||||
int size;
|
||||
char *p;
|
||||
|
||||
if( file == NULL )
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
fseek( file, 0, SEEK_END );
|
||||
size = ftell( file );
|
||||
rewind( file );
|
||||
|
||||
*buffer = bi.Malloc( size + 1 );
|
||||
memset( *buffer, 0, size );
|
||||
fread( *buffer, size, 1, file );
|
||||
|
||||
fclose( file );
|
||||
|
||||
|
||||
p = ( char * )*buffer;
|
||||
p[ size ] = 0;
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
void FS_CanonicalFilename( char *filename )
|
||||
{
|
||||
char *p = filename;
|
||||
|
||||
while( *p )
|
||||
{
|
||||
if( p[ 0 ] == '/' && p[ 1 ] == '/' )
|
||||
{
|
||||
char *p2 = p + 1;
|
||||
|
||||
while( *p2 )
|
||||
{
|
||||
p2[ 0 ] = p2[ 1 ];
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
|
||||
p++;
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __DUMY_BASE_H__
|
||||
#define __DUMY_BASE_H__
|
||||
|
||||
#include <glb_local.h>
|
||||
#include "q_shared.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
void Com_FillBaseImports();
|
||||
void Z_InitMemory();
|
||||
|
||||
void Cmd_Init( void );
|
||||
void Cvar_Init( void );
|
||||
void FS_InitFilesystem( void );
|
||||
|
||||
void BI_Printf( const char *msg, ... );
|
||||
void BI_DPrintf( const char *msg, ... );
|
||||
void BI_Error( int level, const char *msg, ... );
|
||||
int BI_Milliseconds( void );
|
||||
void * BI_Malloc( int size );
|
||||
void BI_Free( void *ptr );
|
||||
int FS_ReadFile2( const char *name, void **buffer, qboolean bSilent );
|
||||
|
||||
//void FS_FreeFile( void *buffer );
|
||||
//int FS_ReadFile( const char *name, void **buffer, bool bSilent );
|
||||
//void FS_CanonicalFilename( char *filename );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __DUMY_BASE_H__ */
|
|
@ -1,60 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#include "game.h"
|
||||
|
||||
Game game;
|
||||
|
||||
void CacheResource( const char *name )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Vector G_GetMovedir( float angle )
|
||||
{
|
||||
if( angle == -1.0f )
|
||||
{
|
||||
return Vector( 0.0f, 0.0f, 1.0f );
|
||||
}
|
||||
else if( angle == -2.0f )
|
||||
{
|
||||
return Vector( 0.0f, 0.0f, -1.0f );
|
||||
}
|
||||
|
||||
angle *= ( M_PI * 2.0f / 360.0f );
|
||||
return Vector( cos( angle ), sin( angle ), 0.0f );
|
||||
}
|
||||
|
||||
float G_Random( float value )
|
||||
{
|
||||
return fmod( rand(), value );
|
||||
}
|
||||
|
||||
CLASS_DECLARATION( Listener, Game, NULL )
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -1,46 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
// game.cpp : TU Level.
|
||||
|
||||
#include "level.h"
|
||||
|
||||
Level level;
|
||||
|
||||
void Level::setTime( int levelTime )
|
||||
{
|
||||
svsTime = levelTime;
|
||||
inttime = levelTime - svsStartTime;
|
||||
svsFloatTime = levelTime / 1000.0f;
|
||||
time = inttime / 1000.0f;
|
||||
}
|
||||
|
||||
void Level::setFrametime( int frametime )
|
||||
{
|
||||
intframetime = frametime;
|
||||
this->frametime = frametime / 1000.0f;
|
||||
}
|
||||
|
||||
CLASS_DECLARATION( Listener, Level, NULL )
|
||||
{
|
||||
{ NULL, NULL }
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __GAME_H__
|
||||
#define __GAME_H__
|
||||
|
||||
#include <listener.h>
|
||||
|
||||
class Game : public Listener {
|
||||
CLASS_PROTOTYPE( Game );
|
||||
};
|
||||
|
||||
extern Game game;
|
||||
|
||||
SimpleEntity *G_FindTarget( SimpleEntity *next, const char *classname );
|
||||
Vector G_GetMovedir( float angle );
|
||||
float G_Random( float value );
|
||||
|
||||
#endif /* __GAME_H__*/
|
|
@ -1,68 +0,0 @@
|
|||
/*
|
||||
===========================================================================
|
||||
Copyright (C) 2015 the OpenMoHAA team
|
||||
|
||||
This file is part of OpenMoHAA source code.
|
||||
|
||||
OpenMoHAA source code is free software; you can redistribute it
|
||||
and/or modify it under the terms of the GNU General Public License as
|
||||
published by the Free Software Foundation; either version 2 of the License,
|
||||
or (at your option) any later version.
|
||||
|
||||
OpenMoHAA source code is distributed in the hope that it will be
|
||||
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenMoHAA source code; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
===========================================================================
|
||||
*/
|
||||
|
||||
#ifndef __LEVEL_H__
|
||||
#define __LEVEL_H__
|
||||
|
||||
#include <listener.h>
|
||||
|
||||
class SimpleArchivedEntity;
|
||||
|
||||
class Level : public Listener {
|
||||
public:
|
||||
bool m_LoopDrop;
|
||||
bool m_LoopProtection;
|
||||
|
||||
str m_mapscript;
|
||||
str current_map;
|
||||
|
||||
// Level time
|
||||
int framenum;
|
||||
int inttime;
|
||||
int intframetime;
|
||||
|
||||
float time;
|
||||
float frametime;
|
||||
|
||||
int spawnflags;
|
||||
|
||||
// Server time
|
||||
int svsTime;
|
||||
float svsFloatTime;
|
||||
int svsStartTime;
|
||||
int svsEndTime;
|
||||
|
||||
bool m_bScriptSpawn;
|
||||
bool m_bRejectSpawn;
|
||||
|
||||
Container< SimpleArchivedEntity * > m_SimpleArchivedEntities;
|
||||
|
||||
public:
|
||||
CLASS_PROTOTYPE( Level );
|
||||
|
||||
void setTime( int _svsTime_ );
|
||||
void setFrametime( int frameTime );
|
||||
};
|
||||
|
||||
extern Level level;
|
||||
|
||||
#endif /* __LEVEL_H__*/
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue