reduce gamecode to a single file
This commit is contained in:
parent
c338156fa2
commit
cc5164a6e5
4 changed files with 83 additions and 157 deletions
|
@ -36,7 +36,6 @@ client_src = [
|
|||
'../engine/water.cc',
|
||||
'../engine/world.cc',
|
||||
'../engine/worldio.cc',
|
||||
'../game/entities.cc',
|
||||
'../game/game.cc',
|
||||
]
|
||||
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
#include "game.hh"
|
||||
|
||||
namespace entities
|
||||
{
|
||||
using namespace game;
|
||||
|
||||
int extraentinfosize() { return 0; } // size in bytes of what the 2 methods below read/write... so it can be skipped by other games
|
||||
|
||||
void writeent(entity &e, char *buf) // write any additional data to disk (except for ET_ ents)
|
||||
{
|
||||
}
|
||||
|
||||
void readent(entity &e, char *buf, int ver) // read from disk, and init
|
||||
{
|
||||
}
|
||||
|
||||
vector<extentity *> ents;
|
||||
|
||||
vector<extentity *> &getents() { return ents; }
|
||||
|
||||
bool mayattach(extentity &e) { return false; }
|
||||
bool attachent(extentity &e, extentity &a) { return false; }
|
||||
|
||||
const char *entmodel(const entity &e)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void preloadentities()
|
||||
{
|
||||
}
|
||||
|
||||
void renderentities()
|
||||
{
|
||||
}
|
||||
|
||||
extentity *newentity() { return new extentity(); }
|
||||
void deleteentity(extentity *e) { delete e; }
|
||||
|
||||
void clearents()
|
||||
{
|
||||
while(ents.length()) deleteentity(ents.pop());
|
||||
}
|
||||
|
||||
void animatemapmodel(const extentity &e, int &anim, int &basetime)
|
||||
{
|
||||
}
|
||||
|
||||
void fixentity(extentity &e)
|
||||
{
|
||||
}
|
||||
|
||||
void entradius(extentity &e, bool color)
|
||||
{
|
||||
}
|
||||
|
||||
bool printent(extentity &e, char *buf, int len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *entnameinfo(entity &e) { return ""; }
|
||||
const char *entname(int i)
|
||||
{
|
||||
static const char * const entnames[MAXENTTYPES] =
|
||||
{
|
||||
"none?", "light", "mapmodel", "playerstart", "envmap", "particles", "sound", "spotlight", "decal",
|
||||
};
|
||||
return i>=0 && size_t(i)<sizeof(entnames)/sizeof(entnames[0]) ? entnames[i] : "";
|
||||
}
|
||||
|
||||
void editent(int i, bool local)
|
||||
{
|
||||
}
|
||||
|
||||
float dropheight(entity &e)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
}
|
||||
|
103
src/game/game.cc
103
src/game/game.cc
|
@ -1,27 +1,17 @@
|
|||
#include "game.hh"
|
||||
#include "cube.hh"
|
||||
|
||||
extern void clearmainmenu();
|
||||
|
||||
namespace game
|
||||
{
|
||||
dynent *player1 = NULL; // our client
|
||||
string clientmap = "";
|
||||
bool connected = false;
|
||||
|
||||
const char *getclientmap() { return clientmap; }
|
||||
|
||||
const char *gameident() { return "OctaForge"; }
|
||||
|
||||
void saveragdoll(dynent *d)
|
||||
{
|
||||
}
|
||||
|
||||
void clearragdolls()
|
||||
{
|
||||
}
|
||||
|
||||
void moveragdolls()
|
||||
{
|
||||
}
|
||||
|
||||
void rendergame()
|
||||
{
|
||||
}
|
||||
|
@ -40,7 +30,6 @@ namespace game
|
|||
|
||||
void preload()
|
||||
{
|
||||
entities::preloadentities();
|
||||
}
|
||||
|
||||
void resetgamestate()
|
||||
|
@ -77,7 +66,6 @@ namespace game
|
|||
if(!curtime) { return; }
|
||||
|
||||
physicsframe();
|
||||
moveragdolls();
|
||||
if(connected)
|
||||
{
|
||||
crouchplayer(player1, 10, true);
|
||||
|
@ -224,8 +212,6 @@ namespace game
|
|||
{
|
||||
}
|
||||
|
||||
bool connected = false;
|
||||
|
||||
void writeclientinfo(stream *f)
|
||||
{
|
||||
}
|
||||
|
@ -240,8 +226,6 @@ namespace game
|
|||
disablezoom();
|
||||
}
|
||||
|
||||
string clientmap = "";
|
||||
|
||||
void changemap(const char *name)
|
||||
{
|
||||
if(editmode) toggleedit();
|
||||
|
@ -303,7 +287,86 @@ namespace game
|
|||
}
|
||||
}
|
||||
|
||||
void toserver(char *text) { conoutf(CON_CHAT, "%s", text); }
|
||||
void toserver(char *text) { }
|
||||
}
|
||||
|
||||
namespace entities
|
||||
{
|
||||
using namespace game;
|
||||
|
||||
int extraentinfosize() { return 0; } // size in bytes of what the 2 methods below read/write... so it can be skipped by other games
|
||||
|
||||
void writeent(entity &e, char *buf) // write any additional data to disk (except for ET_ ents)
|
||||
{
|
||||
}
|
||||
|
||||
void readent(entity &e, char *buf, int ver) // read from disk, and init
|
||||
{
|
||||
}
|
||||
|
||||
vector<extentity *> ents;
|
||||
|
||||
vector<extentity *> &getents() { return ents; }
|
||||
|
||||
bool mayattach(extentity &e) { return false; }
|
||||
bool attachent(extentity &e, extentity &a) { return false; }
|
||||
|
||||
const char *entmodel(const entity &e)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void preloadentities()
|
||||
{
|
||||
}
|
||||
|
||||
void renderentities()
|
||||
{
|
||||
}
|
||||
|
||||
extentity *newentity() { return new extentity(); }
|
||||
void deleteentity(extentity *e) { delete e; }
|
||||
|
||||
void clearents()
|
||||
{
|
||||
while(ents.length()) deleteentity(ents.pop());
|
||||
}
|
||||
|
||||
void animatemapmodel(const extentity &e, int &anim, int &basetime)
|
||||
{
|
||||
}
|
||||
|
||||
void fixentity(extentity &e)
|
||||
{
|
||||
}
|
||||
|
||||
void entradius(extentity &e, bool color)
|
||||
{
|
||||
}
|
||||
|
||||
bool printent(extentity &e, char *buf, int len)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *entnameinfo(entity &e) { return ""; }
|
||||
const char *entname(int i)
|
||||
{
|
||||
static const char * const entnames[ET_GAMESPECIFIC] =
|
||||
{
|
||||
"none?", "light", "mapmodel", "playerstart", "envmap", "particles", "sound", "spotlight", "decal",
|
||||
};
|
||||
return i>=0 && size_t(i)<sizeof(entnames)/sizeof(entnames[0]) ? entnames[i] : "";
|
||||
}
|
||||
|
||||
void editent(int i, bool local)
|
||||
{
|
||||
}
|
||||
|
||||
float dropheight(entity &e)
|
||||
{
|
||||
return 4.0f;
|
||||
}
|
||||
}
|
||||
|
||||
bool haslocalclients() { return game::connected; }
|
||||
|
|
|
@ -1,55 +0,0 @@
|
|||
#ifndef __GAME_H__
|
||||
#define __GAME_H__
|
||||
|
||||
#include "cube.hh"
|
||||
|
||||
// console message types
|
||||
|
||||
enum
|
||||
{
|
||||
CON_CHAT = 1<<8
|
||||
};
|
||||
|
||||
enum // static entity types
|
||||
{
|
||||
NOTUSED = ET_EMPTY, // entity slot not in use in map
|
||||
LIGHT = ET_LIGHT, // lightsource, attr1 = radius, attr2 = intensity
|
||||
MAPMODEL = ET_MAPMODEL, // attr1 = idx, attr2 = yaw, attr3 = pitch, attr4 = roll, attr5 = scale
|
||||
PLAYERSTART, // attr1 = angle, attr2 = team
|
||||
ENVMAP = ET_ENVMAP, // attr1 = radius
|
||||
PARTICLES = ET_PARTICLES,
|
||||
MAPSOUND = ET_SOUND,
|
||||
SPOTLIGHT = ET_SPOTLIGHT,
|
||||
DECAL = ET_DECAL,
|
||||
MAXENTTYPES,
|
||||
|
||||
I_FIRST = 0,
|
||||
I_LAST = -1
|
||||
};
|
||||
|
||||
#define MAXNAMELEN 15
|
||||
|
||||
namespace entities
|
||||
{
|
||||
extern vector<extentity *> ents;
|
||||
extern void preloadentities();
|
||||
}
|
||||
|
||||
namespace game
|
||||
{
|
||||
// game
|
||||
extern string clientmap;
|
||||
|
||||
extern dynent *player1;
|
||||
|
||||
// client
|
||||
extern bool connected;
|
||||
|
||||
// render
|
||||
|
||||
extern void saveragdoll(dynent *d);
|
||||
extern void clearragdolls();
|
||||
extern void moveragdolls();
|
||||
}
|
||||
|
||||
#endif
|
Loading…
Reference in a new issue