From: xolatile Date: Wed, 6 Aug 2025 22:32:29 +0000 (+0200) Subject: More cleanups... X-Git-Url: https://git.xolatile.top/?a=commitdiff_plain;h=4c8dfb375b4b30dbb6079f9d68024980d81ffa20;p=xolatile-badassbug.git More cleanups... --- diff --git a/data/defaults.cfg b/data/defaults.cfg index 71e4687..5c3b907 100644 --- a/data/defaults.cfg +++ b/data/defaults.cfg @@ -175,7 +175,6 @@ editbind F9 [echo (getseltex) : (gettexname (getseltex))] // echo texture info // bind HOME [ edittex 1 ] // bind END [ edittex -1 ] - editbind G [ domodifier 1 ] // domodifier 1 -> executes delta_edit_1 editbind F [ domodifier 2 ] // etc... editbind Q [ domodifier 3 ] diff --git a/data/menus.cfg b/data/menus.cfg index ac60501..a646276 100644 --- a/data/menus.cfg +++ b/data/menus.cfg @@ -723,7 +723,6 @@ newgui ammobar [ ] ] "AmmoBar" - newgui gameclock [ guicheckbox "GameClock" gameclock guibar @@ -761,7 +760,6 @@ newgui gameclock [ ] ] "GameClock" - newgui hudscore [ guicheckbox "HUDScore" hudscore guibar diff --git a/data/stdedit.cfg b/data/stdedit.cfg index 5a319cc..6a13f5f 100644 --- a/data/stdedit.cfg +++ b/data/stdedit.cfg @@ -48,7 +48,6 @@ enttypelist = [ shells bullets rockets riflerounds grenades cartridges health healthboost tinyhealth tinyarmour greenarmour yellowarmour quaddamage teleport teledest jumppad - spotlight ] enttypeselect = [ @@ -63,7 +62,6 @@ enttypeselect = [ ent_action_teleport = [ entproperty 0 ( * $arg1 1 ) ] ent_action_teledest = [ entproperty 1 ( * $arg1 1 ) ] ent_action_mapmodel = [ entproperty 1 ( * $arg1 1 ) ] -ent_action_spotlight = [ entproperty 0 ( * $arg1 5 ) ] ent_action_light = [ entproperty 0 ( * $arg1 5 ) ] ent_action_jumppad = [ entproperty 0 ( * $arg1 5 ) ] ent_action_playerstart = [ entproperty 0 ( * $arg1 15 ) ] diff --git a/src/engine/console.cpp b/src/engine/console.cpp index 1386570..b770bd1 100644 --- a/src/engine/console.cpp +++ b/src/engine/console.cpp @@ -126,7 +126,7 @@ int renderconsole(int w, int h, int abovehud) { // render buffer taking in int conpad = fullconsole ? 0 : FONTH/4, conoff = fullconsole ? FONTH : FONTH/3, conheight = min(fullconsole ? ((h*fullconsize/100)/FONTH)*FONTH : FONTH*consize, h - 2*(conpad + conoff)), - conwidth = w - 2*(conpad + conoff) - (fullconsole ? 0 : game::clipconsole(w, h)); + conwidth = w - 2*(conpad + conoff); extern void consolebox(int x1, int y1, int x2, int y2); if(fullconsole) consolebox(conpad, conpad, conwidth+conpad+2*conoff, conheight+conpad+2*conoff); int y = drawconlines(conskip, fullconsole ? 0 : confade, conwidth, conheight, conpad+conoff, fullconsole ? fullconfilter : confilter); diff --git a/src/engine/engine.h b/src/engine/engine.h index 7bc0ef1..f50a558 100644 --- a/src/engine/engine.h +++ b/src/engine/engine.h @@ -278,9 +278,6 @@ extern void setupmaterials(int start = 0, int len = 0); extern void rendermaterials(); extern int visiblematerial(const cube &c, int orient, const ivec &co, int size, ushort matmask = 0); -// server -extern vector gameargs; - extern void initserver(bool listen, bool dedicated); extern void cleanupserver(); extern void serverslice(bool dedicated, uint timeout); @@ -289,7 +286,6 @@ extern void updatetime(); extern ENetSocket connectmaster(bool wait); extern void localclienttoserver(int chan, ENetPacket *); extern void localconnect(); -extern bool serveroption(char *opt); // serverbrowser extern bool resolverwait(const char *name, ENetAddress *address); @@ -385,7 +381,6 @@ extern vector outsideents; extern void entcancel(); extern void entitiesinoctanodes(); -extern void attachentities(); extern void freeoctaentities(cube &c); extern bool pointinsel(const selinfo &sel, const vec &o); diff --git a/src/engine/lightmap.cpp b/src/engine/lightmap.cpp index 1481de9..0a9daf1 100644 --- a/src/engine/lightmap.cpp +++ b/src/engine/lightmap.cpp @@ -376,12 +376,6 @@ static uint generatelumel(lightmapworker *w, const float tolerance, uint lightma ray.mul(1.0f / mag); float angle = -ray.dot(normal); if(angle <= 0) continue; - if(light.attached && light.attached->type==ET_SPOTLIGHT) { - vec spot = vec(light.attached->o).sub(light.o).normalize(); - float maxatten = sincos360[clamp(int(light.attached->attr1), 1, 89)].x, spotatten = (ray.dot(spot) - maxatten) / (1 - maxatten); - if(spotatten <= 0) continue; - attenuation *= spotatten; - } if(lmshadows && mag) { float dist = shadowray(w->shadowraycache, light.o, ray, mag - tolerance, RAY_SHADOW | (lmshadows > 1 ? RAY_ALPHAPOLY : 0)); if(dist < mag - tolerance) continue; @@ -1738,12 +1732,6 @@ void lightreaching(const vec &target, vec &color, vec &dir, bool fast, extentity float intensity = 1; if(e.attr1) intensity -= mag / float(e.attr1); - if(e.attached && e.attached->type==ET_SPOTLIGHT) { - vec spot = vec(e.attached->o).sub(e.o).normalize(); - float maxatten = sincos360[clamp(int(e.attached->attr1), 1, 89)].x, spotatten = (ray.dot(spot) - maxatten) / (1 - maxatten); - if(spotatten <= 0) continue; - intensity *= spotatten; - } vec lightcol = vec(e.attr2, e.attr3, e.attr4).mul(1.0f/255); color.add(vec(lightcol).mul(intensity)); dir.add(vec(ray).mul(-intensity*lightcol.x*lightcol.y*lightcol.z)); @@ -1773,12 +1761,6 @@ entity *brightestlight(const vec &target, const vec &dir) { float intensity = 1; if(e.attr1) intensity -= mag / float(e.attr1); - if(e.attached && e.attached->type==ET_SPOTLIGHT) { - vec spot = vec(e.attached->o).sub(e.o).normalize(); - float maxatten = sincos360[clamp(int(e.attached->attr1), 1, 89)].x, spotatten = (ray.dot(spot) - maxatten) / (1 - maxatten); - if(spotatten <= 0) continue; - intensity *= spotatten; - } if(!brightest || intensity > bintensity) { brightest = &e; bintensity = intensity; diff --git a/src/engine/main.cpp b/src/engine/main.cpp index a059c13..5e3b1c8 100644 --- a/src/engine/main.cpp +++ b/src/engine/main.cpp @@ -21,7 +21,6 @@ void cleanup() { extern void clear_console(); clear_console(); extern void clear_mdls(); clear_mdls(); extern void clear_sound(); clear_sound(); - closelogfile(); SDL_Quit(); } @@ -899,59 +898,16 @@ int getclockmillis() { VAR(numcpus, 1, 1, 16); -int main(int argc, char **argv) { - setlogfile(NULL); +int main(void) { int dedicated = 0; char *load = NULL, *initscript = NULL; initing = INIT_RESET; - // set home dir first - for(int i = 1; i0, dedicated>1); // never returns if dedicated ASSERT(dedicated <= 1); game::initclient(); diff --git a/src/engine/master.cpp b/src/engine/master.cpp index c1d3e20..92d1b97 100644 --- a/src/engine/master.cpp +++ b/src/engine/master.cpp @@ -20,8 +20,6 @@ #define SERVER_LIMIT 4096 #define SERVER_DUP_LIMIT 10 -FILE *logfile = NULL; - struct userinfo { char *name; void *pubkey; @@ -126,15 +124,15 @@ enet_uint32 servtime = 0; void fatal(const char *fmt, ...) { va_list args; va_start(args, fmt); - vfprintf(logfile, fmt, args); - fputc('\n', logfile); + vfprintf(stdout, fmt, args); + fputc('\n', stdout); va_end(args); exit(EXIT_FAILURE); } void conoutfv(int type, const char *fmt, va_list args) { - vfprintf(logfile, fmt, args); - fputc('\n', logfile); + vfprintf(stdout, fmt, args); + fputc('\n', stdout); } void purgeclient(int n) { @@ -570,9 +568,7 @@ int main(int argc, char **argv) { defformatstring(cfgname, "%smaster.cfg", dir); path(logname); path(cfgname); - logfile = fopen(logname, "a"); - if(!logfile) logfile = stdout; - setvbuf(logfile, NULL, _IOLBF, BUFSIZ); + setvbuf(stdout, NULL, _IOLBF, BUFSIZ); signal(SIGUSR1, reloadsignal); setupserver(port, ip); for(;;) { diff --git a/src/engine/menus.cpp b/src/engine/menus.cpp index e2bd266..e91c6a2 100644 --- a/src/engine/menus.cpp +++ b/src/engine/menus.cpp @@ -411,7 +411,6 @@ void guikeyfield(char *var, int *maxlength, char *onchange) { //use text to do more... - void guilist(uint *contents) { if(!cgui) return; cgui->pushlist(); diff --git a/src/engine/octaedit.cpp b/src/engine/octaedit.cpp index 0da305d..7947e67 100644 --- a/src/engine/octaedit.cpp +++ b/src/engine/octaedit.cpp @@ -1706,7 +1706,6 @@ int shouldpacktex(int index) { return 0; } - bool mpedittex(int tex, int allfaces, selinfo &sel, ucharbuf &buf) { if(!unpacktex(tex, buf)) return false; mpedittex(tex, allfaces, sel, false); diff --git a/src/engine/physics.cpp b/src/engine/physics.cpp index a43e8b4..868bcc1 100644 --- a/src/engine/physics.cpp +++ b/src/engine/physics.cpp @@ -575,7 +575,6 @@ bool plcollide(physent *d, const vec &dir, bool insideplayercol) { // collide wi if(o==d || d->o.reject(o->o, d->radius+o->radius)) continue; if(plcollide(d, dir, o)) { collideplayer = o; - game::dynentcollide(d, o, collidewall); return true; } if(collideinside > lastinside) { @@ -586,7 +585,6 @@ bool plcollide(physent *d, const vec &dir, bool insideplayercol) { // collide wi } if(insideplayer && insideplayercol) { collideplayer = insideplayer; - game::dynentcollide(d, insideplayer, vec(0, 0, 0)); return true; } return false; @@ -1325,7 +1323,7 @@ void modifyvelocity(physent *pl, bool local, bool floating, int curtime) { if(pl->jumping && allowmove) { pl->jumping = false; pl->vel.z = max(pl->vel.z, JUMPVEL); // physics impulse upwards - game::physicstrigger(pl, local, 1); + game::physicstrigger(pl, 1); } } if(!floating && pl->physstate == PHYS_FALL) pl->timeinair = min(pl->timeinair + curtime, 1000); @@ -1400,14 +1398,14 @@ bool moveplayer(physent *pl, int moveres, bool local, int curtime) { d.mul(f); loopi(moveres) if(!move(pl, d) && ++collisions<5) i--; // discrete steps collision detection & sliding if(timeinair > 800 && !pl->timeinair) { // if we land after long time must have been a high jump, make thud sound { - game::physicstrigger(pl, local, -1); + game::physicstrigger(pl, -1); } } if(pl->state==CS_ALIVE) updatedynentcache(pl); // automatically apply smooth roll when strafing if(pl->strafe && maxroll) pl->roll = clamp(pl->roll - pow(clamp(1.0f + pl->strafe*pl->roll/maxroll, 0.0f, 1.0f), 0.33f)*pl->strafe*curtime*straferoll, -maxroll, maxroll); else pl->roll *= curtime == PHYSFRAMETIME ? faderoll : pow(faderoll, curtime/float(PHYSFRAMETIME)); - if(pl->inwater) game::physicstrigger(pl, local, 0, pl->inwater); + if(pl->inwater) game::physicstrigger(pl, 0); pl->inwater = MAT_AIR; if(pl->state==CS_ALIVE && (pl->o.z < 0 || material&MAT_DEATH)) game::suicide(pl); return true; diff --git a/src/engine/rendergl.cpp b/src/engine/rendergl.cpp index b8b28c5..4243ac7 100644 --- a/src/engine/rendergl.cpp +++ b/src/engine/rendergl.cpp @@ -1250,4 +1250,3 @@ void cleanupgl() { gle::cleanup(); } - diff --git a/src/engine/rendermodel.cpp b/src/engine/rendermodel.cpp index bc93caa..0355213 100644 --- a/src/engine/rendermodel.cpp +++ b/src/engine/rendermodel.cpp @@ -194,7 +194,6 @@ COMMAND(mdlname, ""); ragdollskel *ragdoll = skel->ragdoll; \ if(ragdoll->loaded) return; - void rdvert(float *x, float *y, float *z, float *radius) { checkragdoll; ragdollskel::vert &v = ragdoll->verts.add(); @@ -706,7 +705,6 @@ void rendermodel(entitylight *light, const char *mdl, int anim, const vec &o, fl else if(d->type < ENT_CAMERA) pos.z += 0.75f*(d->eyeheight + d->aboveeye); lightreaching(pos, light->color, light->dir, (flags&MDL_LIGHT_FAST)!=0); dynlightreaching(pos, light->color, light->dir, (flags&MDL_HUD)!=0); - game::lighteffects(d, light->color, light->dir); light->millis = lastmillis; } } diff --git a/src/engine/renderva.cpp b/src/engine/renderva.cpp index cc0b65d..dada6d3 100644 --- a/src/engine/renderva.cpp +++ b/src/engine/renderva.cpp @@ -896,7 +896,6 @@ void renderzpass(renderstate &cur, vtxarray *va) { } \ } while(0) - #define endvaquery(va, flush) \ do { \ if(va->query) { \ diff --git a/src/engine/server.cpp b/src/engine/server.cpp index 29761e1..c23e4fa 100644 --- a/src/engine/server.cpp +++ b/src/engine/server.cpp @@ -5,29 +5,6 @@ #define LOGSTRLEN 512 -static FILE *logfile = NULL; - -void closelogfile() { - if(logfile) { - fclose(logfile); - logfile = NULL; - } -} - -FILE *getlogfile() { - return logfile ? logfile : stdout; -} - -void setlogfile(const char *fname) { - closelogfile(); - if(fname && fname[0]) { - fname = findfile(fname, "w"); - if(fname) logfile = fopen(fname, "w"); - } - FILE *f = getlogfile(); - if(f) setvbuf(f, NULL, _IOLBF, BUFSIZ); -} - void logoutf(const char *fmt, ...) { va_list args; va_start(args, fmt); @@ -35,7 +12,6 @@ void logoutf(const char *fmt, ...) { va_end(args); } - static void writelog(FILE *file, const char *buf) { static uchar ubuf[512]; size_t len = strlen(buf), carry = 0; @@ -57,9 +33,8 @@ void fatal(const char *fmt, ...) { void cleanupserver(); cleanupserver(); defvformatstring(msg,fmt,fmt); - if(logfile) logoutf("%s", msg); + logoutf("%s", msg); fprintf(stderr, "server error: %s\n", msg); - closelogfile(); exit(EXIT_FAILURE); } @@ -596,7 +571,7 @@ void localconnect() { #endif void logoutfv(const char *fmt, va_list args) { - FILE *f = getlogfile(); + FILE *f = stdout; if(f) writelogv(f, fmt, args); } @@ -686,32 +661,11 @@ void stoplistenserver() { COMMAND(stoplistenserver, ""); #endif -bool serveroption(char *opt) { - switch(opt[1]) { - case 'u': setvar("serveruprate", atoi(opt+2)); return true; - case 'c': setvar("maxclients", atoi(opt+2)); return true; - case 'i': setsvar("serverip", opt+2); return true; - case 'j': setvar("serverport", atoi(opt+2)); return true; - case 'm': setsvar("mastername", opt+2); setvar("updatemaster", mastername[0] ? 1 : 0); return true; -#ifdef STANDALONE - case 'q': logoutf("Using home directory: %s", opt); sethomedir(opt+2); return true; - case 'k': logoutf("Adding package directory: %s", opt); addpackagedir(opt+2); return true; - case 'g': logoutf("Setting log file: %s", opt); setlogfile(opt+2); return true; -#endif - default: return false; - } -} - -vector gameargs; - #ifdef STANDALONE int main(int argc, char **argv) { - setlogfile(NULL); if(enet_initialize()<0) fatal("Unable to initialise network module"); atexit(enet_deinitialize); enet_time_set(0); - for(int i = 1; i 1) { conoutf(CON_ERROR, "GLSL ERROR (%s:%s)", type == GL_VERTEX_SHADER ? "VS" : (type == GL_FRAGMENT_SHADER ? "FS" : "PROG"), name); - FILE *l = getlogfile(); + FILE *l = stdout; if(l) { GLchar *log = new GLchar[length]; if(type) glGetShaderInfoLog_(obj, length, &length, log); diff --git a/src/engine/textedit.h b/src/engine/textedit.h index 742fd33..21cf980 100644 --- a/src/engine/textedit.h +++ b/src/engine/textedit.h @@ -555,7 +555,6 @@ static editor *useeditor(const char *name, int mode, bool focus, const char *ini return e; } - #define TEXTCOMMAND(f, s, d, body) ICOMMAND(f, s, d,\ editor *top = currentfocus();\ if(!top || identflags&IDF_OVERRIDDEN) return;\ diff --git a/src/engine/world.cpp b/src/engine/world.cpp index 489ea65..f58886f 100644 --- a/src/engine/world.cpp +++ b/src/engine/world.cpp @@ -219,11 +219,6 @@ void findents(int low, int high, bool notspawned, const vec &pos, const vec &rad char *entname(entity &e) { static string fullentname; copystring(fullentname, entities::entname(e.type)); - const char *einfo = entities::entnameinfo(e); - if(*einfo) { - concatstring(fullentname, ": "); - concatstring(fullentname, einfo); - } return fullentname; } @@ -286,71 +281,13 @@ void makeundoent() { if(u) addundo(u); } -void detachentity(extentity &e) { - if(!e.attached) return; - e.attached->attached = NULL; - e.attached = NULL; -} - -VAR(attachradius, 1, 100, 1000); - -void attachentity(extentity &e) { - switch(e.type) { - case ET_SPOTLIGHT: - break; - default: - if(e.type &ents = entities::getents(); - int closest = -1; - float closedist = 1e10f; - loopv(ents) { - extentity *a = ents[i]; - if(a->attached) continue; - switch(e.type) { - case ET_SPOTLIGHT: - if(a->type!=ET_LIGHT) continue; - break; - default: - if(e.typeo); - if(dist < closedist) { - closest = i; - closedist = dist; - } - } - if(closedist>attachradius) return; - e.attached = ents[closest]; - ents[closest]->attached = &e; -} - -void attachentities() { - vector &ents = entities::getents(); - loopv(ents) attachentity(*ents[i]); -} - // convenience macros implicitly define: // e entity, currently edited ent // n int, index to currently edited ent #define addimplicit(f) { if(entgroup.empty() && enthover>=0) { entadd(enthover); undonext = (enthover != oldhover); f; entgroup.drop(); } else f; } -#define entfocusv(i, f, v){ int n = efocus = (i); if(n>=0) { extentity &e = *v[n]; f; } } +#define entfocusv(i, f, v){ int n = efocus = (i); if(n>=0) { extentity &e = *v[n]; f; (void) e; } } #define entfocus(i, f) entfocusv(i, f, entities::getents()) -#define enteditv(i, f, v) { \ - \ - entfocusv(i, { \ - \ - int oldtype = e.type; \ - removeentity(n); \ - f; \ - if(oldtype!=e.type) detachentity(e); \ - if(e.type!=ET_EMPTY) { addentity(n); if(oldtype!=e.type) attachentity(e); } \ - entities::editent(n, true); \ - }, v); \ -} +#define enteditv(i, f, v) { entfocusv(i, { int a = 0; (void) a; }, v); } #define entedit(i, f) enteditv(i, f, entities::getents()) #define addgroup(exp) { vector &ents = entities::getents(); loopv(ents) entfocusv(i, if(exp) entadd(n), ents); } #define setgroup(exp) { entcancel(); addgroup(exp); } @@ -490,15 +427,6 @@ void renderentsphere(const extentity &e, float radius) { loopk(3) renderentring(e, radius, k); } -void renderentattachment(const extentity &e) { - if(!e.attached) return; - gle::defvertex(); - gle::begin(GL_LINES); - gle::attrib(e.o); - gle::attrib(e.attached->o); - xtraverts += gle::end(); -} - void renderentarrow(const extentity &e, const vec &dir, float radius) { if(radius <= 0) return; float arrowsize = min(radius/8, 0.5f); @@ -541,17 +469,6 @@ void renderentradius(extentity &e, bool color) { if(color) gle::colorf(e.attr2/255.0f, e.attr3/255.0f, e.attr4/255.0f); renderentsphere(e, e.attr1); break; - case ET_SPOTLIGHT: - if(e.attached) { - if(color) gle::colorf(0, 1, 1); - float radius = e.attached->attr1; - if(!radius) radius = 2*e.o.dist(e.attached->o); - vec dir = vec(e.o).sub(e.attached->o).normalize(); - float angle = clamp(int(e.attr1), 1, 89); - renderentattachment(e); - renderentcone(*e.attached, dir, radius, angle); - } - break; case ET_SOUND: if(color) gle::colorf(0, 1, 1); renderentsphere(e, e.attr2); @@ -559,7 +476,7 @@ void renderentradius(extentity &e, bool color) { case ET_MAPMODEL: case ET_PLAYERSTART: { if(color) gle::colorf(0, 1, 1); - entities::entradius(e, color); + entities::entradius(e); vec dir; vecfromyawpitch(e.attr1, 0, 1, 0, dir); renderentarrow(e, dir, 4); @@ -568,7 +485,7 @@ void renderentradius(extentity &e, bool color) { default: if(e.type>=ET_GAMESPECIFIC) { if(color) gle::colorf(0, 1, 1); - entities::entradius(e, color); + entities::entradius(e); } break; } @@ -744,8 +661,7 @@ bool dropentity(entity &e, int drop = -1) { } switch(drop) { case 1: - if(e.type != ET_LIGHT && e.type != ET_SPOTLIGHT) - dropenttofloor(&e); + dropenttofloor(&e); break; case 2: case 3: @@ -774,13 +690,6 @@ void dropent() { groupedit(dropentity(e)); } -void attachent() { - if(noentedit()) return; - groupedit(attachentity(e)); -} - -COMMAND(attachent, ""); - VARP(entcamdir, 0, 1, 1); static int keepents = 0; @@ -881,24 +790,7 @@ void entset(char *what, int *a1, int *a2, int *a3, int *a4, int *a5) { if(noentedit()) return; int type = findtype(what); if(type != ET_EMPTY) - groupedit(e.type=type; - e.attr1=*a1; - e.attr2=*a2; - e.attr3=*a3; - e.attr4=*a4; - e.attr5=*a5); -} - -void printent(extentity &e, char *buf, int len) { - switch(e.type) { - case ET_PARTICLES: - if(printparticles(e, buf, len)) return; - break; - default: - if(e.type >= ET_GAMESPECIFIC && entities::printent(e, buf, len)) return; - break; - } - nformatstring(buf, len, "%s %d %d %d %d %d", entities::entname(e.type), e.attr1, e.attr2, e.attr3, e.attr4, e.attr5); + groupedit(e.type=type; e.attr1=*a1; e.attr2=*a2; e.attr3=*a3; e.attr4=*a4; e.attr5=*a5); } void nearestent() { @@ -922,7 +814,6 @@ ICOMMAND(enthavesel,"", (), addimplicit(intret(entgroup.length()))); ICOMMAND(entselect, "e", (uint *body), if(!noentedit()) addgroup(e.type != ET_EMPTY && entgroup.find(n)<0 && executebool(body))); ICOMMAND(entloop, "e", (uint *body), if(!noentedit()) addimplicit(groupeditloop(((void)e, execute(body))))); ICOMMAND(insel, "", (), entfocus(efocus, intret(pointinsel(sel, e.o)))); -ICOMMAND(entget, "", (), entfocus(efocus, string s; printent(e, s, sizeof(s)); result(s))); ICOMMAND(entindex, "", (), intret(efocus)); COMMAND(entset, "siiiii"); COMMAND(nearestent, ""); @@ -1153,18 +1044,6 @@ void mpeditent(int i, const vec &o, int type, int attr1, int attr2, int attr3, i extentity *e = newentity(local, o, type, attr1, attr2, attr3, attr4, attr5, i); if(!e) return; addentity(i); - attachentity(*e); - } - else { - extentity &e = *ents[i]; - removeentity(i); - int oldtype = e.type; - if(oldtype!=type) detachentity(e); - e.type = type; - e.o = o; - e.attr1 = attr1; e.attr2 = attr2; e.attr3 = attr3; e.attr4 = attr4; e.attr5 = attr5; - addentity(i); - if(oldtype!=type) attachentity(e); } entities::editent(i, local); } diff --git a/src/engine/worldio.cpp b/src/engine/worldio.cpp index 898b2bb..e64e0da 100644 --- a/src/engine/worldio.cpp +++ b/src/engine/worldio.cpp @@ -556,11 +556,8 @@ bool save_world(const char *mname, bool nolms) { break; } }); - f->putchar((int)strlen(game::gameident())); - f->write(game::gameident(), (int)strlen(game::gameident())+1); f->putlil(entities::extraentinfosize()); vector extras; - game::writegamedata(extras); f->putlil(extras.length()); f->write(extras.getbuf(), extras.length()); f->putlil(texmru.length()); @@ -615,7 +612,6 @@ bool load_world(const char *mname, const char *cname) { // still supports all m resetmap(); Texture *mapshot = textureload(picname, 3, true, false); renderbackground("loading...", mapshot, mname, game::getmapinfo()); - game::loadingmap(cname ? cname : mname); setvar("mapversion", hdr.version, true, false); lilswap(&hdr.numvslots, 1); renderprogress(0, "clearing world..."); @@ -663,7 +659,6 @@ bool load_world(const char *mname, const char *cname) { // still supports all m int extrasize = f->getlil(); vector extras; f->read(extras.pad(extrasize), extrasize); - game::readgamedata(extras); texmru.shrink(0); ushort nummru = f->getlil(); loopi(nummru) texmru.add(f->getlil()); @@ -679,9 +674,7 @@ bool load_world(const char *mname, const char *cname) { // still supports all m lilswap(&e.attr1, 5); if(einfosize > 0) f->read(ebuf, einfosize); if(!insideworld(e.o)) { - if(e.type != ET_LIGHT && e.type != ET_SPOTLIGHT) { - conoutf(CON_WARN, "warning: ent outside of world: enttype[%s] index %d (%f, %f, %f)", entities::entname(e.type), i, e.o.x, e.o.y, e.o.z); - } + conoutf(CON_WARN, "warning: ent outside of world: enttype[%s] index %d (%f, %f, %f)", entities::entname(e.type), i, e.o.x, e.o.y, e.o.z); } } if(ebuf) delete[] ebuf; @@ -727,7 +720,6 @@ bool load_world(const char *mname, const char *cname) { // still supports all m flushpreloadedmodels(); preloadmapsounds(); entitiesinoctanodes(); - attachentities(); initlights(); allchanged(true); renderbackground("loading...", mapshot, mname, game::getmapinfo()); diff --git a/src/fpsgame/ai.h b/src/fpsgame/ai.h index b6db1fc..40c8513 100644 --- a/src/fpsgame/ai.h +++ b/src/fpsgame/ai.h @@ -236,4 +236,3 @@ namespace ai { extern void render(); } - diff --git a/src/fpsgame/entities.cpp b/src/fpsgame/entities.cpp index 9336c4e..21d44a6 100644 --- a/src/fpsgame/entities.cpp +++ b/src/fpsgame/entities.cpp @@ -9,8 +9,6 @@ namespace entities { #ifndef STANDALONE vector ents; vector &getents() { return ents; } - bool mayattach(extentity &e) { return false; } - bool attachent(extentity &e, extentity &a) { return false; } const char *itemname(int i) { int t = ents[i]->type; if(tI_QUAD) return NULL; @@ -306,7 +304,7 @@ namespace entities { void fixentity(extentity &e) { if(e.type == TELEDEST) e.attr3 = e.attr2; } - void entradius(extentity &e, bool color) { + void entradius(extentity &e) { switch(e.type) { case TELEDEST: { vec dir; @@ -326,13 +324,9 @@ namespace entities { default: break; } } - 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[] = { - "none?", "light", "mapmodel", "playerstart", "none?", "particles", "sound", "spotlight", + "none?", "light", "mapmodel", "playerstart", "none?", "particles", "sound", "shells", "bullets", "rockets", "riflerounds", "grenades", "cartridges", "health", "healthboost", "tinyhealth", "tinyarmour", "greenarmour", "yellowarmour", "quaddamage", "teleport", "teledest", @@ -345,7 +339,5 @@ namespace entities { extentity &e = *ents[i]; if(local) addmsg(N_EDITENT, "rii3ii5", i, (int)(e.o.x*DMF), (int)(e.o.y*DMF), (int)(e.o.z*DMF), e.type, e.attr1, e.attr2, e.attr3, e.attr4, e.attr5); } - #endif } - diff --git a/src/fpsgame/fps.cpp b/src/fpsgame/fps.cpp index c74f5f4..eadb2c8 100644 --- a/src/fpsgame/fps.cpp +++ b/src/fpsgame/fps.cpp @@ -9,7 +9,6 @@ namespace game { fpsent *player1 = NULL; // our client vector players; // other clients int savedammo[NUMGUNS]; - bool clientoption(const char *arg) { return false; } void taunt() { if(player1->state!=CS_ALIVE || player1->physstatelasttaunt<1000) return; @@ -454,9 +453,6 @@ namespace game { lasthit = 0; execident("mapstart"); } - void loadingmap(const char *name) { - execident("playsong"); - } void startmap(const char *name) { // called just after a map load { pwreset(); ai::savewaypoints(); @@ -474,14 +470,11 @@ namespace game { const char *getscreenshotinfo() { return server::modename(gamemode, NULL); } - void physicstrigger(physent *d, bool local, int floorlevel, int material) { + void physicstrigger(physent *d, int floorlevel) { if(d->type==ENT_INANIMATE) return; - if (floorlevel>0) { if(d==player1 || d->type!=ENT_PLAYER || ((fpsent *)d)->ai) msgsound(S_JUMP, d); } + if (floorlevel>0) { if(d==player1 || d->type!=ENT_PLAYER || ((fpsent *)d)->ai) msgsound(S_JUMP, d); } else if(floorlevel<0) { if(d==player1 || d->type!=ENT_PLAYER || ((fpsent *)d)->ai) msgsound(S_LAND, d); } } - void dynentcollide(physent *d, physent *o, const vec &dir) { - return; - } void msgsound(int n, physent *d) { if(!d || d==player1) { addmsg(N_SOUND, "ci", d, n); @@ -564,6 +557,7 @@ namespace game { gle::end(); } float abovegameplayhud(int w, int h) { + (void)w;(void)h; switch(hudplayer()->state) { case CS_EDITING: case CS_SPECTATOR: @@ -888,9 +882,6 @@ namespace game { pophudmatrix(); } } - int clipconsole(int w, int h) { - return 0; - } VARP(teamcrosshair, 0, 1, 1); VARP(hitcrosshair, 0, 425, 1000); const char *defaultcrosshair(int index) { @@ -920,15 +911,6 @@ namespace game { if(d->gunwait) color.mul(0.5f); return crosshair; } - void lighteffects(dynent *e, vec &color, vec &dir) { -#if 0 - fpsent *d = (fpsent *)e; - if(d->state!=CS_DEAD && d->quadmillis) { - float t = 0.5f + 0.5f*sinf(2*M_PI*lastmillis/1000.0f); - color.y = color.y*(1-t) + t; - } -#endif - } int maxsoundradius(int n) { switch(n) { case S_JUMP: @@ -1038,8 +1020,6 @@ namespace game { return false; } // any data written into this vector will get saved with the map data. Must take care to do own versioning, and endianess if applicable. Will not get called when loading maps from other games, so provide defaults. - void writegamedata(vector &extras) {} - void readgamedata(vector &extras) {} const char *savedconfig() { return "config.cfg"; } const char *restoreconfig() { return "restore.cfg"; } const char *defaultconfig() { return "data/defaults.cfg"; } diff --git a/src/fpsgame/game.h b/src/fpsgame/game.h index 974f1f3..dadebd5 100644 --- a/src/fpsgame/game.h +++ b/src/fpsgame/game.h @@ -26,7 +26,6 @@ enum { // static entity types { PLAYERSTART, // attr1 = angle, attr2 = team PARTICLES = ET_PARTICLES, MAPSOUND = ET_SOUND, - SPOTLIGHT = ET_SPOTLIGHT, I_SHELLS, I_BULLETS, I_ROCKETS, I_ROUNDS, I_GRENADES, I_CARTRIDGES, I_HEALTH, I_BOOST, /**/I_TINYHEALTH, I_TINYARMOUR, @@ -510,7 +509,6 @@ namespace game { extern int respawnent; extern int following; extern int smoothmove, smoothdist; - extern bool clientoption(const char *arg); extern fpsent *getclient(int cn); extern fpsent *newclient(int cn); extern const char *colorname(fpsent *d, const char *name = NULL, const char *prefix = "", const char *suffix = "", const char *alt = NULL); @@ -613,7 +611,6 @@ namespace server { extern void forcegamespeed(int speed); extern void hashpassword(int cn, int sessionid, const char *pwd, char *result, int maxlen = MAXSTRLEN); extern int msgsizelookup(int msg); - extern bool serveroption(const char *arg); extern bool delayspawn(int type); } diff --git a/src/fpsgame/scoreboard.cpp b/src/fpsgame/scoreboard.cpp index 81f93a1..b1c7477 100644 --- a/src/fpsgame/scoreboard.cpp +++ b/src/fpsgame/scoreboard.cpp @@ -112,6 +112,7 @@ namespace game { return color; } void renderscoreboard(g3d_gui &g, bool firstpass) { + (void) firstpass; const ENetAddress *address = connectedpeer(); if(showservinfo && address) { string hostname; diff --git a/src/fpsgame/server.cpp b/src/fpsgame/server.cpp index 2095dd1..7070fb8 100644 --- a/src/fpsgame/server.cpp +++ b/src/fpsgame/server.cpp @@ -1,17 +1,5 @@ #include "game.h" -namespace game { - void parseoptions(vector &args) { - loopv(args) -#ifndef STANDALONE - if(!game::clientoption(args[i])) -#endif - if(!server::serveroption(args[i])) - conoutf(CON_ERROR, "unknown command-line option: %s", args[i]); - } - const char *gameident() { return "fps"; } -} - VAR(regenbluearmour, 0, 1, 1); extern ENetAddress masteraddress; @@ -573,15 +561,6 @@ namespace server { sents.setsize(0); //cps.reset(); } - bool serveroption(const char *arg) { - if(arg[0]=='-') switch(arg[1]) { - case 'n': setsvar("serverdesc", &arg[2]); return true; - case 'y': setsvar("serverpass", &arg[2]); return true; - case 'p': setsvar("adminpass", &arg[2]); return true; - case 'o': setvar("publicserver", atoi(&arg[2])); return true; - } - return false; - } void serverinit() { smapname[0] = '\0'; resetitems(); diff --git a/src/shared/ents.h b/src/shared/ents.h index 6b1dfca..fece7bf 100644 --- a/src/shared/ents.h +++ b/src/shared/ents.h @@ -3,7 +3,7 @@ // ET_*: the only static entity types dictated by the engine... rest are gamecode dependent -enum { ET_EMPTY=0, ET_LIGHT, ET_MAPMODEL, ET_PLAYERSTART, ET_PARTICLES, ET_SOUND, ET_SPOTLIGHT, ET_GAMESPECIFIC }; +enum { ET_EMPTY=0, ET_LIGHT, ET_MAPMODEL, ET_PLAYERSTART, ET_PARTICLES, ET_SOUND, ET_GAMESPECIFIC }; // persistent map entity struct entity { @@ -35,8 +35,7 @@ enum { struct extentity : entity { int flags; // the only dynamic state of a map entity entitylight light; - extentity *attached; - extentity() : flags(0), attached(NULL) {} + extentity() : flags(0) {} bool spawned() const { return (flags&EF_SPAWNED) != 0; } void setspawned(bool val) { if(val) flags |= EF_SPAWNED; else flags &= ~EF_SPAWNED; } void setspawned() { flags |= EF_SPAWNED; } diff --git a/src/shared/geom.cpp b/src/shared/geom.cpp index ad71841..13a75dc 100644 --- a/src/shared/geom.cpp +++ b/src/shared/geom.cpp @@ -235,4 +235,3 @@ extern const vec2 sincos360[721] = { vec2(0.99452190, -0.10452846), vec2(0.99619470, -0.08715574), vec2(0.99756405, -0.06975647), vec2(0.99862953, -0.05233596), vec2(0.99939083, -0.03489950), vec2(0.99984770, -0.01745241), // 714 vec2(1.00000000, 0.00000000) // 720 }; - diff --git a/src/shared/iengine.h b/src/shared/iengine.h index f4e822d..3b2c662 100644 --- a/src/shared/iengine.h +++ b/src/shared/iengine.h @@ -186,9 +186,6 @@ extern void conoutf(int type, const char *s, ...) PRINTFARGS(2, 3); extern void conoutf(int type, int tag, const char *s, ...) PRINTFARGS(3, 4); extern void conoutfv(int type, const char *fmt, va_list args); -extern FILE *getlogfile(); -extern void setlogfile(const char *fname); -extern void closelogfile(); extern void logoutfv(const char *fmt, va_list args); extern void logoutf(const char *fmt, ...) PRINTFARGS(1, 2); @@ -222,7 +219,6 @@ extern int getworldsize(); extern int getmapversion(); extern void renderentcone(const extentity &e, const vec &dir, float radius, float angle); extern void renderentarrow(const extentity &e, const vec &dir, float radius); -extern void renderentattachment(const extentity &e); extern void renderentsphere(const extentity &e, float radius); extern void renderentring(const extentity &e, float radius, int axis = 0); diff --git a/src/shared/igame.h b/src/shared/igame.h index 03a9163..4b0e933 100644 --- a/src/shared/igame.h +++ b/src/shared/igame.h @@ -2,14 +2,10 @@ namespace entities { extern void editent(int i, bool local); - extern const char *entnameinfo(entity &e); extern const char *entname(int i); extern int extraentinfosize(); extern void fixentity(extentity &e); - extern void entradius(extentity &e, bool color); - extern bool mayattach(extentity &e); - extern bool attachent(extentity &e, extentity &a); - extern bool printent(extentity &e, char *buf, int len); + extern void entradius(extentity &e); extern extentity *newentity(); extern void deleteentity(extentity *e); extern void clearents(); @@ -18,7 +14,6 @@ namespace entities { } namespace game { - extern void parseoptions(vector &args); extern void gamedisconnect(bool cleanup); extern void parsepacketclient(int chan, packetbuf &p); extern void connectattempt(const char *name, const char *password, const ENetAddress &address); @@ -33,7 +28,6 @@ namespace game { extern bool ispaused(); extern int scaletime(int t); extern bool allowmouselook(); - extern const char *gameident(); extern const char *savedconfig(); extern const char *restoreconfig(); extern const char *defaultconfig(); @@ -42,11 +36,10 @@ namespace game { extern void loadconfigs(); extern void updateworld(); extern void initclient(); - extern void physicstrigger(physent *d, bool local, int floorlevel, int material = 0); + extern void physicstrigger(physent *d, int floorlevel); extern void bounced(physent *d, const vec &surface); extern void edittrigger(const selinfo &sel, int op, int arg1 = 0, int arg2 = 0, int arg3 = 0, const VSlot *vs = NULL); extern void vartrigger(ident *id); - extern void dynentcollide(physent *d, physent *o, const vec &dir); extern const char *getclientmap(); extern const char *getmapinfo(); extern const char *getscreenshotinfo(); @@ -54,7 +47,6 @@ namespace game { extern void suicide(physent *d); extern float ratespawn(dynent *d, const extentity &e); extern void newmap(int size); - extern void loadingmap(const char *name); extern void startmap(const char *name); extern void preload(); extern float abovegameplayhud(int w, int h); @@ -67,13 +59,9 @@ namespace game { extern void rendergame(bool mainpass); extern void renderavatar(); extern void renderplayerpreview(int model, int team, int weap); - extern void writegamedata(vector &extras); - extern void readgamedata(vector &extras); - extern int clipconsole(int w, int h); extern void g3d_gamemenus(); extern const char *defaultcrosshair(int index); extern int selectcrosshair(vec &color); - extern void lighteffects(dynent *d, vec &color, vec &dir); extern void setupcamera(); extern bool allowthirdperson(bool msg = false); extern bool detachcamera(); diff --git a/src/shared/stream.cpp b/src/shared/stream.cpp index 1878801..3a5c6e2 100644 --- a/src/shared/stream.cpp +++ b/src/shared/stream.cpp @@ -232,7 +232,6 @@ done: #include #include -string homedir = ""; struct packagedir { char *dir, *filter; size_t dirlen, filterlen; @@ -260,7 +259,6 @@ char *makerelpath(const char *dir, const char *file, const char *prefix, const c return tmp; } - char *path(char *s) { for(char *curpart = s;;) { char *endpart = strchr(curpart, '&'); @@ -330,75 +328,8 @@ bool createdir(const char *path) { return mkdir(path, 0777)==0; } -size_t fixpackagedir(char *dir) { - path(dir); - size_t len = strlen(dir); - if(len > 0 && dir[len-1] != PATHDIV) { - dir[len] = PATHDIV; - dir[len+1] = '\0'; - } - return len; -} - -bool subhomedir(char *dst, int len, const char *src) { - const char *sub = strstr(src, "$HOME"); - if(!sub) sub = strchr(src, '~'); - if(sub && sub-src < len) { - const char *home = getenv("HOME"); - if(!home || !home[0]) return false; - dst[sub-src] = '\0'; - concatstring(dst, home, len); - concatstring(dst, sub+(*sub == '~' ? 1 : strlen("$HOME")), len); - } - return true; -} - -const char *sethomedir(const char *dir) { - string pdir; - copystring(pdir, dir); - if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL; - copystring(homedir, pdir); - return homedir; -} - -const char *addpackagedir(const char *dir) { - string pdir; - copystring(pdir, dir); - if(!subhomedir(pdir, sizeof(pdir), dir) || !fixpackagedir(pdir)) return NULL; - char *filter = pdir; - for(;;) { - static int len = strlen("packages"); - filter = strstr(filter, "packages"); - if(!filter) break; - if(filter > pdir && filter[-1] == PATHDIV && filter[len] == PATHDIV) break; - filter += len; - } - packagedir &pf = packagedirs.add(); - pf.dir = filter ? newstring(pdir, filter-pdir) : newstring(pdir); - pf.dirlen = filter ? filter-pdir : strlen(pdir); - pf.filter = filter ? newstring(filter) : NULL; - pf.filterlen = filter ? strlen(filter) : 0; - return pf.dir; -} - const char *findfile(const char *filename, const char *mode) { static string s; - if(homedir[0]) { - formatstring(s, "%s%s", homedir, filename); - if(fileexists(s, mode)) return s; - if(mode[0]=='w' || mode[0]=='a') { - string dirs; - copystring(dirs, s); - char *dir = strchr(dirs[0]==PATHDIV ? dirs+1 : dirs, PATHDIV); - while(dir) { - *dir = '\0'; - if(!fileexists(dirs, "d") && !createdir(dirs)) return s; - *dir = PATHDIV; - dir = strchr(dir+1, PATHDIV); - } - return s; - } - } if(mode[0]=='w' || mode[0]=='a') return filename; loopv(packagedirs) { packagedir &pf = packagedirs[i]; @@ -442,10 +373,8 @@ int listfiles(const char *dir, const char *ext, vector &files) { int dirs = 0; if(listdir(dirname, true, ext, files)) dirs++; string s; - if(homedir[0]) { - formatstring(s, "%s%s", homedir, dirname); - if(listdir(s, false, ext, files)) dirs++; - } + formatstring(s, "%s%s", ".", dirname); + if(listdir(s, false, ext, files)) dirs++; loopv(packagedirs) { packagedir &pf = packagedirs[i]; if(pf.filter && strncmp(dirname, pf.filter, dirlen == pf.filterlen-1 ? dirlen : pf.filterlen)) diff --git a/src/shared/tools.h b/src/shared/tools.h index 709f056..6e7eeab 100644 --- a/src/shared/tools.h +++ b/src/shared/tools.h @@ -1012,17 +1012,12 @@ static inline uchar cubeupper(uchar c) { extern size_t decodeutf8(uchar *dst, size_t dstlen, const uchar *src, size_t srclen, size_t *carry = NULL); extern size_t encodeutf8(uchar *dstbuf, size_t dstlen, const uchar *srcbuf, size_t srclen, size_t *carry = NULL); -extern string homedir; - extern char *makerelpath(const char *dir, const char *file, const char *prefix = NULL, const char *cmd = NULL); extern char *path(char *s); extern char *path(const char *s, bool copy); extern const char *parentdir(const char *directory); extern bool fileexists(const char *path, const char *mode); extern bool createdir(const char *path); -extern size_t fixpackagedir(char *dir); -extern const char *sethomedir(const char *dir); -extern const char *addpackagedir(const char *dir); extern const char *findfile(const char *filename, const char *mode); extern bool findzipfile(const char *filename); extern stream *openrawfile(const char *filename, const char *mode); diff --git a/src/shared/zip.cpp b/src/shared/zip.cpp index c60ea16..98ac8fb 100644 --- a/src/shared/zip.cpp +++ b/src/shared/zip.cpp @@ -200,7 +200,6 @@ static void mountzip(ziparchive &arch, vector &files, const char *mount string mdir = "", fname; if(mountdir) { copystring(mdir, mountdir); - if(fixpackagedir(mdir) <= 1) mdir[0] = '\0'; } loopv(files) { zipfile &f = files[i];