From d6466cee3d5d868e69be7b94051db7d921583478 Mon Sep 17 00:00:00 2001 From: q66 Date: Wed, 10 Jun 2020 01:46:45 +0200 Subject: [PATCH] add main.hh, physics.hh --- src/engine/console.cc | 1 + src/engine/engine.hh | 57 -------------------- src/engine/light.cc | 2 + src/engine/main.cc | 97 +++++++++++++++++++---------------- src/engine/main.hh | 43 ++++++++++++++++ src/engine/movie.cc | 3 ++ src/engine/normal.cc | 1 + src/engine/octa.cc | 2 + src/engine/octaedit.cc | 1 + src/engine/octarender.cc | 1 + src/engine/physics.cc | 50 +++++++++--------- src/engine/physics.hh | 12 +++++ src/engine/pvs.cc | 2 + src/engine/rendergl.cc | 1 + src/engine/rendergl.hh | 2 + src/engine/renderlights.cc | 1 + src/engine/rendermodel.cc | 1 + src/engine/renderparticles.cc | 1 + src/engine/renderva.cc | 2 + src/engine/shader.cc | 1 + src/engine/stain.cc | 1 + src/engine/texture.cc | 2 + src/engine/world.cc | 2 + src/engine/worldio.cc | 1 + 24 files changed, 162 insertions(+), 125 deletions(-) create mode 100644 src/engine/main.hh create mode 100644 src/engine/physics.hh diff --git a/src/engine/console.cc b/src/engine/console.cc index 1e312f3..da4ea60 100644 --- a/src/engine/console.cc +++ b/src/engine/console.cc @@ -1,5 +1,6 @@ // console.cpp: the console buffer, its display, and command line control +#include "main.hh" #include "octaedit.hh" // editmode #include "rendertext.hh" diff --git a/src/engine/engine.hh b/src/engine/engine.hh index 1010dd0..4f650b2 100644 --- a/src/engine/engine.hh +++ b/src/engine/engine.hh @@ -4,8 +4,6 @@ #include "cube.hh" #include "world.hh" -#ifndef STANDALONE - #include "light.hh" #include "bih.hh" @@ -21,10 +19,6 @@ extern const ivec facecoords[6][4]; extern const uchar fv[6][4]; extern const uchar fvmasks[64]; extern const uchar faceedgesidx[6][4]; -extern bool inbetweenframes, renderedframe; - -extern SDL_Window *screen; -extern int screenw, screenh; // renderlights @@ -101,10 +95,6 @@ extern void updatedynlights(); extern int finddynlights(); extern bool getdynlight(int n, vec &o, float &radius, vec &color, vec &dir, int &spot, int &flags); -// client -extern void localdisconnect(bool cleanup = true); -extern void clientkeepalive(); - // command extern hashnameset idents; extern int identflags; @@ -133,52 +123,5 @@ extern tagval *addreleaseaction(ident *id, int numargs); extern void writebinds(stream *f); extern void writecompletions(stream *f); -// main - -extern int mainmenu; - -extern void clearmainmenu(); - -enum -{ - NOT_INITING = 0, - INIT_GAME, - INIT_LOAD, - INIT_RESET -}; -extern int initing, numcpus; - -extern bool initwarning(const char *desc, int level = INIT_RESET, int type = 0); - -extern bool grabinput, minimized; - -extern void pushevent(const SDL_Event &e); -extern bool interceptkey(int sym); - -extern float loadprogress; -extern void renderbackground(const char *caption = NULL, Texture *mapshot = NULL, const char *mapname = NULL, const char *mapinfo = NULL, bool force = false); -extern void renderprogress(float bar, const char *text, bool background = false); - -extern void getframemillis(float &avg, float &best, float &worst); -extern void getfps(int &fps, int &bestdiff, int &worstdiff); -extern void swapbuffers(bool overlay = true); -extern int getclockmillis(); - -enum { KR_CONSOLE = 1<<0, KR_GUI = 1<<1, KR_EDITMODE = 1<<2 }; - -extern void keyrepeat(bool on, int mask = ~0); - -enum { TI_CONSOLE = 1<<0, TI_GUI = 1<<1 }; - -extern void textinput(bool on, int mask = ~0); - -// physics -extern void mousemove(int dx, int dy); -extern bool overlapsdynent(const vec &o, float radius); -extern void rotatebb(vec ¢er, vec &radius, int yaw, int pitch, int roll = 0); -extern float shadowray(const vec &o, const vec &ray, float radius, int mode, extentity *t = NULL); - -#endif - #endif diff --git a/src/engine/light.cc b/src/engine/light.cc index 043eb75..b76fdb9 100644 --- a/src/engine/light.cc +++ b/src/engine/light.cc @@ -1,6 +1,8 @@ #include "blend.hh" +#include "main.hh" // renderbackground #include "octa.hh" #include "octaedit.hh" // commitchanges +#include "physics.hh" #include "renderlights.hh" #include "texture.hh" diff --git a/src/engine/main.cc b/src/engine/main.cc index 17631b8..9661297 100644 --- a/src/engine/main.cc +++ b/src/engine/main.cc @@ -1,5 +1,7 @@ // main.cpp: initialisation & main loop +#include "main.hh" + #include "blend.hh" #include "movie.hh" #include "octaedit.hh" @@ -16,6 +18,11 @@ #include "engine.hh" +static SDL_Window *screen = NULL; +static int curvsync = -1; + +static void swapbuffers(bool overlay = true); + VAR(mainmenu, 1, 1, 0); void clientkeepalive() {} @@ -39,13 +46,13 @@ void clearmainmenu() } } -void localdisconnect(bool cleanup) +static void localdisconnect() { - game::gamedisconnect(cleanup); + game::gamedisconnect(true); mainmenu = 1; } -void trydisconnect() +static void trydisconnect() { if(haslocalclients()) localdisconnect(); else conoutf("not connected"); @@ -53,9 +60,9 @@ void trydisconnect() ICOMMAND(disconnect, "", (), trydisconnect()); -extern void cleargamma(); +static void cleargamma(); -void cleanup() +static void cleanup() { recorder::stop(); SDL_ShowCursor(SDL_TRUE); @@ -74,9 +81,9 @@ void cleanup() SDL_Quit(); } -extern void writeinitcfg(); +static void writeinitcfg(); -void quit() // normal exit +static void quit() // normal exit { writeinitcfg(); localdisconnect(); @@ -118,8 +125,7 @@ void fatal(const char *s, ...) // failure exit VAR(desktopw, 1, 0, 0); VAR(desktoph, 1, 0, 0); int screenw = 0, screenh = 0; -SDL_Window *screen = NULL; -SDL_GLContext glcontext = NULL; +static SDL_GLContext glcontext = NULL; int curtime = 0, lastmillis = 1, elapsedtime = 0, totalmillis = 1; @@ -146,7 +152,7 @@ bool initwarning(const char *desc, int level, int type) VARFN(screenw, scr_w, SCR_MINW, -1, SCR_MAXW, initwarning("screen resolution")); VARFN(screenh, scr_h, SCR_MINH, -1, SCR_MAXH, initwarning("screen resolution")); -void writeinitcfg() +static void writeinitcfg() { stream *f = openutf8file("config/init.cfg", "w"); if(!f) return; @@ -170,12 +176,12 @@ static void getbackgroundres(int &w, int &h) h = int(ceil(h*hk)); } -string backgroundcaption = ""; -Texture *backgroundmapshot = NULL; -string backgroundmapname = ""; -char *backgroundmapinfo = NULL; +static string backgroundcaption = ""; +static Texture *backgroundmapshot = NULL; +static string backgroundmapname = ""; +static char *backgroundmapinfo = NULL; -void bgquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1) +static void bgquad(float x, float y, float w, float h, float tx = 0, float ty = 0, float tw = 1, float th = 1) { gle::begin(GL_TRIANGLE_STRIP); gle::attribf(x, y); gle::attribf(tx, ty); @@ -185,7 +191,7 @@ void bgquad(float x, float y, float w, float h, float tx = 0, float ty = 0, floa gle::end(); } -void renderbackgroundview(int w, int h, const char *caption, Texture *mapshot, const char *mapname, const char *mapinfo) +static void renderbackgroundview(int w, int h, const char *caption, Texture *mapshot, const char *mapname, const char *mapinfo) { static int lastupdate = -1, lastw = -1, lasth = -1; static float backgroundu = 0, backgroundv = 0; @@ -276,7 +282,7 @@ void renderbackgroundview(int w, int h, const char *caption, Texture *mapshot, c VAR(menumute, 0, 1, 1); -void setbackgroundinfo(const char *caption = NULL, Texture *mapshot = NULL, const char *mapname = NULL, const char *mapinfo = NULL) +static void setbackgroundinfo(const char *caption = NULL, Texture *mapshot = NULL, const char *mapname = NULL, const char *mapinfo = NULL) { renderedframe = false; copystring(backgroundcaption, caption ? caption : ""); @@ -315,7 +321,7 @@ void renderbackground(const char *caption, Texture *mapshot, const char *mapname setbackgroundinfo(caption, mapshot, mapname, mapinfo); } -void restorebackground(int w, int h, bool force = false) +static void restorebackground(int w, int h, bool force = false) { if(renderedframe) { @@ -327,7 +333,7 @@ void restorebackground(int w, int h, bool force = false) float loadprogress = 0; -void renderprogressview(int w, int h, float bar, const char *text) // also used during loading +static void renderprogressview(int w, int h, float bar, const char *text) // also used during loading { hudmatrix.ortho(0, w, h, 0, -1, 1); resethudmatrix(); @@ -400,7 +406,7 @@ void renderprogress(float bar, const char *text, bool background) // also used getbackgroundres(w, h); gettextres(w, h); - extern int mesa_swap_bug, curvsync; + extern int mesa_swap_bug; bool forcebackground = progressbackground || (mesa_swap_bug && (curvsync || totalmillis==1)); if(background || forcebackground) restorebackground(w, h, forcebackground); @@ -410,9 +416,11 @@ void renderprogress(float bar, const char *text, bool background) // also used VARNP(relativemouse, userelativemouse, 0, 1, 1); -bool shouldgrab = false, grabinput = false, minimized = false, canrelativemouse = true, relativemouse = false; -int keyrepeatmask = 0, textinputmask = 0; -Uint32 textinputtime = 0; +static bool shouldgrab = false, grabinput = false; +static bool canrelativemouse = true, relativemouse = false; +bool minimized = false; +static int keyrepeatmask = 0, textinputmask = 0; +static Uint32 textinputtime = 0; VAR(textinputfilter, 0, 5, 1000); void keyrepeat(bool on, int mask) @@ -439,7 +447,7 @@ void textinput(bool on, int mask) } } -void inputgrab(bool on) +static void inputgrab(bool on) { if(on) { @@ -472,9 +480,9 @@ void inputgrab(bool on) shouldgrab = false; } -bool initwindowpos = false; +static bool initwindowpos = false; -void setfullscreen(bool enable) +static void setfullscreen(bool enable) { if(!screen) return; //initwarning(enable ? "fullscreen" : "windowed"); @@ -497,7 +505,7 @@ VARF(fullscreen, 0, 0, 1, setfullscreen(fullscreen!=0)); VARF(fullscreen, 0, 1, 1, setfullscreen(fullscreen!=0)); #endif -void screenres(int w, int h) +static void screenres(int w, int h) { scr_w = clamp(w, SCR_MINW, SCR_MAXW); scr_h = clamp(h, SCR_MINH, SCR_MAXH); @@ -529,20 +537,19 @@ VARFNP(gamma, reqgamma, 30, 100, 300, setgamma(curgamma); }); -void restoregamma() +static void restoregamma() { if(initing || reqgamma == 100) return; curgamma = reqgamma; setgamma(curgamma); } -void cleargamma() +static void cleargamma() { if(curgamma != 100 && screen) SDL_SetWindowBrightness(screen, 1.0f); } -int curvsync = -1; -void restorevsync() +static void restorevsync() { if(initing || !glcontext) return; extern int vsync, vsynctear; @@ -555,7 +562,7 @@ VARFP(vsynctear, 0, 0, 1, { if(vsync) restorevsync(); }); VAR(dbgmodes, 0, 0, 1); -void setupscreen() +static void setupscreen() { if(glcontext) { @@ -621,7 +628,7 @@ void setupscreen() hudh = screenh; } -void resetgl() +static void resetgl() { //clearchanges(CHANGE_GFX|CHANGE_SHADERS); @@ -669,9 +676,9 @@ void resetgl() COMMAND(resetgl, ""); -vector events; +static vector events; -void pushevent(const SDL_Event &e) +static void pushevent(const SDL_Event &e) { events.add(e); } @@ -767,7 +774,7 @@ static void checkmousemotion(int &dx, int &dy) } } -void checkinput() +static void checkinput() { SDL_Event event; //int lasttype = 0, lastbut = 0; @@ -875,7 +882,7 @@ void checkinput() if(mousemoved) resetmousemotion(); } -void swapbuffers(bool overlay) +static void swapbuffers(bool overlay) { recorder::capture(overlay); gle::disable(); @@ -885,7 +892,7 @@ void swapbuffers(bool overlay) VAR(menufps, 0, 60, 1000); VARP(maxfps, 0, 125, 1000); -void limitfps(int &millis, int curmillis) +static void limitfps(int &millis, int curmillis) { int limit = (mainmenu || minimized) && menufps ? (maxfps ? min(maxfps, menufps) : menufps) : maxfps; if(!limit) return; @@ -929,7 +936,7 @@ __declspec(dllexport) #endif #if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__) -void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep) +static void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep) { if(!ep) fatal("unknown type"); EXCEPTION_RECORD *er = ep->ExceptionRecord; @@ -972,21 +979,22 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep) #define MAXFPSHISTORY 60 -int fpspos = 0, fpshistory[MAXFPSHISTORY]; +static int fpspos = 0, fpshistory[MAXFPSHISTORY]; -void resetfpshistory() +static void resetfpshistory() { loopi(MAXFPSHISTORY) fpshistory[i] = 1; fpspos = 0; } -void updatefpshistory(int millis) +static void updatefpshistory(int millis) { fpshistory[fpspos++] = max(1, min(1000, millis)); if(fpspos>=MAXFPSHISTORY) fpspos = 0; } -void getframemillis(float &avg, float &bestdiff, float &worstdiff) +#if 0 +static void getframemillis(float &avg, float &bestdiff, float &worstdiff) { int total = fpshistory[MAXFPSHISTORY-1], best = total, worst = total; loopi(MAXFPSHISTORY-1) @@ -1001,6 +1009,7 @@ void getframemillis(float &avg, float &bestdiff, float &worstdiff) best = best - avg; worstdiff = avg - worst; } +#endif void getfps(int &fps, int &bestdiff, int &worstdiff) { @@ -1018,7 +1027,7 @@ void getfps(int &fps, int &bestdiff, int &worstdiff) worstdiff = fps-1000/worst; } -void getfps_(int *raw) +static void getfps_(int *raw) { if(*raw) floatret(1000.0f/fpshistory[(fpspos+MAXFPSHISTORY-1)%MAXFPSHISTORY]); else diff --git a/src/engine/main.hh b/src/engine/main.hh new file mode 100644 index 0000000..bf5a26b --- /dev/null +++ b/src/engine/main.hh @@ -0,0 +1,43 @@ +#ifndef ENGINE_MAIN_HH +#define ENGINE_MAIN_HH + +#include + +extern int initing, numcpus; +extern int mainmenu; +extern int screenw, screenh; +extern bool minimized; +extern float loadprogress; +extern bool inbetweenframes, renderedframe; + +void clearmainmenu(); + +enum +{ + NOT_INITING = 0, + INIT_GAME, + INIT_LOAD, + INIT_RESET +}; + +bool initwarning(const char *desc, int level = INIT_RESET, int type = 0); + +bool interceptkey(int sym); + +struct Texture; + +void renderbackground(const char *caption = NULL, Texture *mapshot = NULL, const char *mapname = NULL, const char *mapinfo = NULL, bool force = false); +void renderprogress(float bar, const char *text, bool background = false); + +void getfps(int &fps, int &bestdiff, int &worstdiff); +int getclockmillis(); + +enum { KR_CONSOLE = 1<<0, KR_GUI = 1<<1, KR_EDITMODE = 1<<2 }; + +void keyrepeat(bool on, int mask = ~0); + +enum { TI_CONSOLE = 1<<0, TI_GUI = 1<<1 }; + +void textinput(bool on, int mask = ~0); + +#endif diff --git a/src/engine/movie.cc b/src/engine/movie.cc index a0be841..42496dc 100644 --- a/src/engine/movie.cc +++ b/src/engine/movie.cc @@ -7,6 +7,9 @@ // avidemux - ok - 3Apr09-RockKeyman:had to swap UV channels as it showed up blue // kino - ok +#include "movie.hh" + +#include "main.hh" // getfps, getclockmillis, screenw/h, inbetweenframes, renderedframe #include "rendergl.hh" #include "rendertext.hh" #include "texture.hh" diff --git a/src/engine/normal.cc b/src/engine/normal.cc index 6529b96..c5845df 100644 --- a/src/engine/normal.cc +++ b/src/engine/normal.cc @@ -1,3 +1,4 @@ +#include "main.hh" // renderprogress #include "texture.hh" #include "engine.hh" diff --git a/src/engine/octa.cc b/src/engine/octa.cc index ee71715..d96492b 100644 --- a/src/engine/octa.cc +++ b/src/engine/octa.cc @@ -1,6 +1,8 @@ // core world management routines #include "octa.hh" + +#include "main.hh" // renderprogress #include "octaedit.hh" #include "world.hh" diff --git a/src/engine/octaedit.cc b/src/engine/octaedit.cc index 5263588..39bd183 100644 --- a/src/engine/octaedit.cc +++ b/src/engine/octaedit.cc @@ -1,6 +1,7 @@ #include "octaedit.hh" #include "blend.hh" +#include "main.hh" // mainmenu, keyrepeat, renderedframe #include "material.hh" #include "octa.hh" #include "pvs.hh" diff --git a/src/engine/octarender.cc b/src/engine/octarender.cc index c552641..ed316dd 100644 --- a/src/engine/octarender.cc +++ b/src/engine/octarender.cc @@ -2,6 +2,7 @@ #include "blend.hh" #include "grass.hh" +#include "main.hh" // mainmenu, laodprogress #include "material.hh" #include "rendergl.hh" #include "renderlights.hh" diff --git a/src/engine/physics.cc b/src/engine/physics.cc index 6ebab10..7ebd8f1 100644 --- a/src/engine/physics.cc +++ b/src/engine/physics.cc @@ -3,6 +3,8 @@ // they "felt right", and have no basis in reality. Collision detection is simplistic but // very robust (uses discrete steps at fixed fps). +#include "physics.hh" + #include "rendermodel.hh" #include "octa.hh" #include "world.hh" @@ -111,7 +113,7 @@ void resetclipplanes() else if(v[i] < p.o[i]-p.r[i] || v[i] > p.o[i]+p.r[i]) exit; \ } -vec hitsurface; +vec hitsurface; /* extern'd */ static inline bool raycubeintersect(const clipplanes &p, const cube &c, const vec &v, const vec &ray, const vec &invray, float maxdist, float &dist) { @@ -128,8 +130,8 @@ static inline bool raycubeintersect(const clipplanes &p, const cube &c, const ve return true; } -float hitentdist; -int hitent, hitorient; +static float hitentdist; +static int hitent, hitorient; static float disttoent(octaentities *oc, const vec &o, const vec &ray, float radius, int mode, extentity *t) { @@ -434,7 +436,7 @@ const float WALLZ = 0.2f; extern const float JUMPVEL = 125.0f; extern const float GRAVITY = 200.0f; -bool ellipseboxcollide(physent *d, const vec &dir, const vec &o, const vec ¢er, float yaw, float xr, float yr, float hi, float lo) +static bool ellipseboxcollide(physent *d, const vec &dir, const vec &o, const vec ¢er, float yaw, float xr, float yr, float hi, float lo) { float below = (o.z+center.z-lo) - (d->o.z+d->aboveeye), above = (d->o.z-d->eyeheight) - (o.z+center.z+hi); @@ -489,7 +491,7 @@ bool ellipseboxcollide(physent *d, const vec &dir, const vec &o, const vec ¢ return false; } -bool ellipsecollide(physent *d, const vec &dir, const vec &o, const vec ¢er, float yaw, float xr, float yr, float hi, float lo) +static bool ellipsecollide(physent *d, const vec &dir, const vec &o, const vec ¢er, float yaw, float xr, float yr, float hi, float lo) { float below = (o.z+center.z-lo) - (d->o.z+d->aboveeye), above = (d->o.z-d->eyeheight) - (o.z+center.z+hi); @@ -549,7 +551,7 @@ VARF(dynentsize, 4, 7, 12, cleardynentcache()); #define DYNENTHASH(x, y) (((((x)^(y))<<5) + (((x)^(y))>>5)) & (DYNENTCACHESIZE - 1)) -const vector &checkdynentcache(int x, int y) +static const vector &checkdynentcache(int x, int y) { dynentcacheentry &dec = dynentcache[DYNENTHASH(x, y)]; if(dec.x == x && dec.y == y && dec.frame == dynentframe) return dec.dynents; @@ -628,7 +630,7 @@ static inline bool plcollide(physent *d, const vec &dir, physent *o) } } -bool plcollide(physent *d, const vec &dir, bool insideplayercol) // collide with player +static bool plcollide(physent *d, const vec &dir, bool insideplayercol) // collide with player { if(d->type==ENT_CAMERA || d->state!=CS_ALIVE) return false; int lastinside = collideinside; @@ -801,7 +803,7 @@ static bool fuzzycollideellipse(physent *d, const vec &dir, float cutoff, const VAR(testtricol, 0, 0, 2); -bool mmcollide(physent *d, const vec &dir, float cutoff, octaentities &oc) // collide with a mapmodel +static bool mmcollide(physent *d, const vec &dir, float cutoff, octaentities &oc) // collide with a mapmodel { const vector &ents = entities::getents(); loopv(oc.mapmodels) @@ -1153,7 +1155,7 @@ bool collide(physent *d, const vec &dir, float cutoff, bool playercol, bool insi return octacollide(d, dir, cutoff, bo, bs) || (playercol && plcollide(d, dir, insideplayercol)); // collide with world } -void recalcdir(physent *d, const vec &oldvel, vec &dir) +static void recalcdir(physent *d, const vec &oldvel, vec &dir) { float speed = oldvel.magnitude(); if(speed > 1e-6f) @@ -1165,7 +1167,7 @@ void recalcdir(physent *d, const vec &oldvel, vec &dir) } } -void slideagainst(physent *d, vec &dir, const vec &obstacle, bool foundfloor, bool slidecollide) +static void slideagainst(physent *d, vec &dir, const vec &obstacle, bool foundfloor, bool slidecollide) { vec wall(obstacle); if(foundfloor ? wall.z > 0 : slidecollide) @@ -1180,7 +1182,7 @@ void slideagainst(physent *d, vec &dir, const vec &obstacle, bool foundfloor, bo recalcdir(d, oldvel, dir); } -void switchfloor(physent *d, vec &dir, const vec &floor) +static void switchfloor(physent *d, vec &dir, const vec &floor) { if(floor.z >= FLOORZ) d->falling = vec(0, 0, 0); @@ -1196,7 +1198,7 @@ void switchfloor(physent *d, vec &dir, const vec &floor) recalcdir(d, oldvel, dir); } -bool trystepup(physent *d, vec &dir, const vec &obstacle, float maxstep, const vec &floor) +static bool trystepup(physent *d, vec &dir, const vec &obstacle, float maxstep, const vec &floor) { vec old(d->o), stairdir = (obstacle.z >= 0 && obstacle.z < SLOPEZ ? vec(-obstacle.x, -obstacle.y, 0) : vec(dir.x, dir.y, 0)).rescale(1); bool cansmooth = true; @@ -1287,7 +1289,7 @@ bool trystepup(physent *d, vec &dir, const vec &obstacle, float maxstep, const v return false; } -bool trystepdown(physent *d, vec &dir, float step, float xy, float z, bool init = false) +static bool trystepdown(physent *d, vec &dir, float step, float xy, float z, bool init = false) { vec stepdir(dir.x, dir.y, 0); stepdir.z = -stepdir.magnitude2()*z/xy; @@ -1338,7 +1340,7 @@ bool trystepdown(physent *d, vec &dir, float step, float xy, float z, bool init return false; } -bool trystepdown(physent *d, vec &dir, bool init = false) +static bool trystepdown(physent *d, vec &dir, bool init = false) { if((!d->move && !d->strafe) || !game::allowmove(d)) return false; vec old(d->o); @@ -1364,7 +1366,7 @@ bool trystepdown(physent *d, vec &dir, bool init = false) return false; } -void falling(physent *d, vec &dir, const vec &floor) +static void falling(physent *d, vec &dir, const vec &floor) { if(floor.z > 0.0f && floor.z < SLOPEZ) { @@ -1377,7 +1379,7 @@ void falling(physent *d, vec &dir, const vec &floor) d->physstate = PHYS_FALL; } -void landing(physent *d, vec &dir, const vec &floor, bool collided) +static void landing(physent *d, vec &dir, const vec &floor, bool collided) { #if 0 if(d->physstate == PHYS_FALL) @@ -1393,7 +1395,7 @@ void landing(physent *d, vec &dir, const vec &floor, bool collided) d->floor = floor; } -bool findfloor(physent *d, const vec &dir, bool collided, const vec &obstacle, bool &slide, vec &floor) +static bool findfloor(physent *d, const vec &dir, bool collided, const vec &obstacle, bool &slide, vec &floor) { bool found = false; vec moved(d->o); @@ -1451,7 +1453,7 @@ foundfloor: return found; } -bool move(physent *d, vec &dir) +static bool move(physent *d, vec &dir) { vec old(d->o); bool collided = false, slidecollide = false; @@ -1673,7 +1675,7 @@ bool droptofloor(vec &o, float radius, float height) return false; } -float dropheight(entity &e) +static float dropheight(entity &e) { switch(e.type) { @@ -1690,7 +1692,7 @@ void dropenttofloor(entity *e) droptofloor(e->o, 1.0f, dropheight(*e)); } -void phystest() +static void phystest() { static const char * const states[] = {"float", "fall", "slide", "slope", "floor", "step up", "step down", "bounce"}; printf ("PHYS(pl): %s, air %d, floor: (%f, %f, %f), vel: (%f, %f, %f), g: (%f, %f, %f)\n", states[player->physstate], player->timeinair, player->floor.x, player->floor.y, player->floor.z, player->vel.x, player->vel.y, player->vel.z, player->falling.x, player->falling.y, player->falling.z); @@ -1740,7 +1742,7 @@ FVAR(straferoll, 0, 0.033f, 90); FVAR(faderoll, 0, 0.95f, 1); VAR(floatspeed, 1, 100, 10000); -void modifyvelocity(physent *pl, bool local, bool water, bool floating, int curtime) +static void modifyvelocity(physent *pl, bool local, bool water, bool floating, int curtime) { bool allowmove = game::allowmove(pl); if(floating) @@ -1801,7 +1803,7 @@ void modifyvelocity(physent *pl, bool local, bool water, bool floating, int curt // pl->vel.lerp(pl->vel, d, fpsfric); } -void modifygravity(physent *pl, bool water, int curtime) +static void modifygravity(physent *pl, bool water, int curtime) { float secs = curtime/1000.0f; vec g(0, 0, 0); @@ -1898,7 +1900,7 @@ bool moveplayer(physent *pl, int moveres, bool local, int curtime) return true; } -int physsteps = 0, physframetime = PHYSFRAMETIME, lastphysframe = 0; +static int physsteps = 0, physframetime = PHYSFRAMETIME, lastphysframe = 0; void physicsframe() // optimally schedule physics frames inside the graphics frames { @@ -1915,7 +1917,7 @@ void physicsframe() // optimally schedule physics frames inside the gra VAR(physinterp, 0, 1, 1); -void interppos(physent *pl) +static void interppos(physent *pl) { pl->o = pl->newpos; diff --git a/src/engine/physics.hh b/src/engine/physics.hh new file mode 100644 index 0000000..37b0caf --- /dev/null +++ b/src/engine/physics.hh @@ -0,0 +1,12 @@ +#ifndef ENGINE_PHYSICS_HH +#define ENGINE_PHYSICS_HH + +#include + +struct extentity; + +bool overlapsdynent(const vec &o, float radius); +void rotatebb(vec ¢er, vec &radius, int yaw, int pitch, int roll = 0); +float shadowray(const vec &o, const vec &ray, float radius, int mode, extentity *t = NULL); + +#endif diff --git a/src/engine/pvs.cc b/src/engine/pvs.cc index 7febc4a..c910a7b 100644 --- a/src/engine/pvs.cc +++ b/src/engine/pvs.cc @@ -1,4 +1,6 @@ #include "pvs.hh" + +#include "main.hh" // numcpus, interceptkey, renderbackground #include "octa.hh" #include "engine.hh" diff --git a/src/engine/rendergl.cc b/src/engine/rendergl.cc index b0c1e14..f957110 100644 --- a/src/engine/rendergl.cc +++ b/src/engine/rendergl.cc @@ -3,6 +3,7 @@ #include "aa.hh" #include "blend.hh" #include "grass.hh" +#include "main.hh" // mainmenu, renderbackground, getfps, getclockmillis, screenw/h, inbetweenframes, renderedframe #include "material.hh" #include "pvs.hh" #include "octaedit.hh" diff --git a/src/engine/rendergl.hh b/src/engine/rendergl.hh index 60c207f..76dd22c 100644 --- a/src/engine/rendergl.hh +++ b/src/engine/rendergl.hh @@ -80,4 +80,6 @@ struct cubemapside; /* texture.hh */ void drawcubemap(int size, const vec &o, float yaw, float pitch, const cubemapside &side, bool onlysky = false); +void mousemove(int dx, int dy); + #endif diff --git a/src/engine/renderlights.cc b/src/engine/renderlights.cc index 48775e7..6ddec6b 100644 --- a/src/engine/renderlights.cc +++ b/src/engine/renderlights.cc @@ -1,6 +1,7 @@ #include "renderlights.hh" #include "aa.hh" +#include "main.hh" // initwarning #include "material.hh" #include "octaedit.hh" // editmode #include "pvs.hh" diff --git a/src/engine/rendermodel.cc b/src/engine/rendermodel.cc index 6e2f754..a510540 100644 --- a/src/engine/rendermodel.cc +++ b/src/engine/rendermodel.cc @@ -1,6 +1,7 @@ #include "rendermodel.hh" #include "aa.hh" +#include "main.hh" // loadprogress, renderprogress #include "pvs.hh" #include "rendergl.hh" #include "renderva.hh" diff --git a/src/engine/renderparticles.cc b/src/engine/renderparticles.cc index 5988acd..e0607b6 100644 --- a/src/engine/renderparticles.cc +++ b/src/engine/renderparticles.cc @@ -1,5 +1,6 @@ // renderparticles.cpp +#include "main.hh" // initing, minimized, loadprogress #include "renderparticles.hh" #include "octaedit.hh" // editmode #include "pvs.hh" diff --git a/src/engine/renderva.cc b/src/engine/renderva.cc index d915be4..d4a7d41 100644 --- a/src/engine/renderva.cc +++ b/src/engine/renderva.cc @@ -1,8 +1,10 @@ // renderva.cpp: handles the occlusion and rendering of vertex arrays #include "renderva.hh" + #include "blend.hh" #include "grass.hh" +#include "main.hh" // renderprogress #include "octaedit.hh" // editmode #include "pvs.hh" #include "rendergl.hh" diff --git a/src/engine/shader.cc b/src/engine/shader.cc index 6256d16..6470664 100644 --- a/src/engine/shader.cc +++ b/src/engine/shader.cc @@ -1,5 +1,6 @@ // shader.cpp: OpenGL GLSL shader management +#include "main.hh" // loadprogress, renderprogress #include "rendergl.hh" #include "rendermodel.hh" // cleanupmodels #include "shader.hh" diff --git a/src/engine/stain.cc b/src/engine/stain.cc index 3f701cf..0be7203 100644 --- a/src/engine/stain.cc +++ b/src/engine/stain.cc @@ -1,3 +1,4 @@ +#include "main.hh" // initing, loadprogress #include "material.hh" #include "rendergl.hh" #include "rendermodel.hh" // loadmapmodel diff --git a/src/engine/texture.cc b/src/engine/texture.cc index 64d81bf..8bb68e1 100644 --- a/src/engine/texture.cc +++ b/src/engine/texture.cc @@ -1,5 +1,6 @@ // texture.cpp: texture slot management +#include "main.hh" // initwarning, loadprogress, renderprogress, screenw/h, renderedframe #include "material.hh" #include "octaedit.hh" #include "rendergl.hh" @@ -3059,6 +3060,7 @@ static GLuint genenvmap(const vec &o, int envmapsize, int blur, bool onlysky) } glBindFramebuffer_(GL_FRAMEBUFFER, 0); glViewport(0, 0, hudw, hudh); + extern void clientkeepalive(); /* FIXME */ clientkeepalive(); return tex; } diff --git a/src/engine/world.cc b/src/engine/world.cc index f293645..8e54c1e 100644 --- a/src/engine/world.cc +++ b/src/engine/world.cc @@ -1,8 +1,10 @@ // world.cpp: core map management stuff #include "blend.hh" +#include "main.hh" // clearmainmenu #include "octa.hh" #include "octaedit.hh" +#include "physics.hh" #include "pvs.hh" #include "rendergl.hh" /* fovy */ #include "renderlights.hh" diff --git a/src/engine/worldio.cc b/src/engine/worldio.cc index bc331fd..ec8319d 100644 --- a/src/engine/worldio.cc +++ b/src/engine/worldio.cc @@ -1,6 +1,7 @@ // worldio.cpp: loading & saving of maps and savegames #include "blend.hh" +#include "main.hh" // clearmainmenu, renderbackground #include "octa.hh" #include "octaedit.hh" // texmru #include "pvs.hh"