From 050772c523ce745db07fee8a5223375a8e481daa Mon Sep 17 00:00:00 2001 From: ac_stef Date: Mon, 9 Feb 2009 13:40:44 +0000 Subject: [PATCH] 16 minor fixes git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4153 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/audiomanager.cpp | 164 ++++++++++++++++++------------------ source/src/client.cpp | 2 +- source/src/clientgame.cpp | 3 +- source/src/docs.cpp | 50 +++++------ source/src/server.cpp | 4 +- source/src/tools.cpp | 2 +- 6 files changed, 112 insertions(+), 113 deletions(-) diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 0415ba93..00b5ae65 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -33,7 +33,7 @@ void audiomanager::initsound() device = NULL; context = NULL; - // list available devices + // list available devices if(alcIsExtensionPresent(NULL, "ALC_ENUMERATION_EXT")) { const ALCchar *devices = alcGetString(NULL, ALC_DEVICE_SPECIFIER); @@ -48,7 +48,7 @@ void audiomanager::initsound() if(c!=devices) s_strcat(d, ", "); s_strcat(d, c); } - conoutf(d); + conoutf("%s", d); } } @@ -64,14 +64,14 @@ void audiomanager::initsound() alcMakeContextCurrent(context); alDistanceModel(AL_INVERSE_DISTANCE_CLAMPED); - + // backend infos conoutf("Sound: %s / %s (%s)", alcGetString(device, ALC_DEVICE_SPECIFIER), alGetString(AL_RENDERER), alGetString(AL_VENDOR)); conoutf("Driver: %s", alGetString(AL_VERSION)); // allocate OpenAL resources sourcescheduler::instance().init(16); - + // let the stream get the first source from the scheduler gamemusic = new oggstream(); if(!gamemusic->valid) DELETEP(gamemusic); @@ -178,7 +178,7 @@ int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vectorload()) conoutf("\f3failed to load sample %s", name); - + soundconfig s(b, vol, maxuses, loop, audibleradius); sounds.add(s); return sounds.length()-1; @@ -197,7 +197,7 @@ void audiomanager::preloadmapsound(entity &e) { if(e.type!=SOUND || !mapsounds.inrange(e.attr1)) return; sbuffer *buf = mapsounds[e.attr1].buf; - if(!buf->load()) conoutf("\f3failed to load sample %s", buf->name); + if(!buf->load()) conoutf("\f3failed to load sample %s", buf->name); } void audiomanager::preloadmapsounds() @@ -237,10 +237,10 @@ void audiomanager::soundcleanup() locations.deletecontentsp(); gamesounds.setsize(0); bufferpool.clear(); - + // kill scheduler sourcescheduler::instance().reset(); - + // shutdown openal alcMakeContextCurrent(NULL); if(context) alcDestroyContext(context); @@ -273,14 +273,14 @@ void audiomanager::updateplayerfootsteps(playerent *p) // find existing footstep sounds physentreference ref(p); - location *locs[] = + location *locs[] = { locations.find(S_FOOTSTEPS, &ref, gamesounds), locations.find(S_FOOTSTEPSCROUCH, &ref, gamesounds), locations.find(S_WATERFOOTSTEPS, &ref, gamesounds), locations.find(S_WATERFOOTSTEPSCROUCH, &ref, gamesounds) }; - + bool local = (p == camera1); bool inrange = footsteps && (local || (camera1->o.dist(p->o) < footstepradius)); @@ -297,7 +297,7 @@ void audiomanager::updateplayerfootsteps(playerent *p) l->drop(); } } - else + else { // play footsteps @@ -314,7 +314,7 @@ void audiomanager::updateplayerfootsteps(playerent *p) loopi(sizeof(locs)/sizeof(locs[0])) { location *l = locs[i]; - if(!l) continue; + if(!l) continue; if(i+S_FOOTSTEPS==stepsound) isplaying = true; // already playing else l->drop(); // different footstep sound, drop it } @@ -421,13 +421,13 @@ soundconfig::soundconfig(sbuffer *b, int vol, int maxuses, bool loop, int audibl } void soundconfig::onattach() -{ - uses++; +{ + uses++; } void soundconfig::ondetach() -{ - uses--; +{ + uses--; } vector gamesounds, mapsounds; @@ -458,7 +458,7 @@ location *audiomanager::_playsound(int n, const worldobjreference &r, int priori static int soundsatonce = 0, lastsoundmillis = 0; if(totalmillis==lastsoundmillis) soundsatonce++; else soundsatonce = 1; lastsoundmillis = totalmillis; - if(maxsoundsatonce && soundsatonce>maxsoundsatonce) + if(maxsoundsatonce && soundsatonce>maxsoundsatonce) { DEBUGVAR(soundsatonce); return NULL; @@ -482,8 +482,8 @@ void audiomanager::playsound(int n, physent *p, int priority) { if(p) _playsound void audiomanager::playsound(int n, entity *e, int priority) { if(e) _playsound(n, entityreference(e), priority); } void audiomanager::playsound(int n, const vec *v, int priority) { if(v) _playsound(n, staticreference(*v), priority); } -void audiomanager::playsoundname(char *s, const vec *loc, int vol) -{ +void audiomanager::playsoundname(char *s, const vec *loc, int vol) +{ if(!nosound) return; if(vol <= 0) vol = 100; @@ -493,7 +493,7 @@ void audiomanager::playsoundname(char *s, const vec *loc, int vol) } void audiomanager::playsoundc(int n, physent *p) -{ +{ if(p && p!=player1) playsound(n, p); else { @@ -506,7 +506,7 @@ void audiomanager::stopsound() { if(nosound) return; DELETEA(musicdonecmd); - if(gamemusic) gamemusic->reset(); + if(gamemusic) gamemusic->reset(); } // main audio update routine @@ -516,12 +516,12 @@ void audiomanager::updateaudio() if(nosound) return; alcSuspendContext(context); // don't process sounds while we mess around - - //bool alive = player1->state!=CS_DEAD; + + //bool alive = player1->state!=CS_DEAD; bool firstperson = camera1==player1 || (player1->isspectating() && player1->spectatemode==SM_DEATHCAM); // footsteps - updateplayerfootsteps(player1); + updateplayerfootsteps(player1); loopv(players) { playerent *p = players[i]; @@ -549,7 +549,7 @@ void audiomanager::updateaudio() else if(!pitchfx && currentpitch==lowpitch) { currentpitch = 1.0f; - locations.forcepitch(currentpitch); + locations.forcepitch(currentpitch); } // update map sounds @@ -620,24 +620,24 @@ void audiomanager::updateaudio() camerareference::camerareference() : worldobjreference(WR_CAMERA) {} -worldobjreference *camerareference::clone() const -{ - return new camerareference(*this); +worldobjreference *camerareference::clone() const +{ + return new camerareference(*this); } -const vec &camerareference::currentposition() const -{ - return camera1->o; +const vec &camerareference::currentposition() const +{ + return camera1->o; } -bool camerareference::nodistance() -{ - return true; +bool camerareference::nodistance() +{ + return true; } -bool camerareference::operator==(const worldobjreference &other) -{ - return type==other.type; +bool camerareference::operator==(const worldobjreference &other) +{ + return type==other.type; } // physent @@ -648,24 +648,24 @@ physentreference::physentreference(physent *ref) : worldobjreference(WR_PHYSENT) phys = ref; } -worldobjreference *physentreference::clone() const -{ - return new physentreference(*this); +worldobjreference *physentreference::clone() const +{ + return new physentreference(*this); } -const vec &physentreference::currentposition() const -{ - return phys->o; +const vec &physentreference::currentposition() const +{ + return phys->o; } -bool physentreference::nodistance() -{ - return phys==camera1; +bool physentreference::nodistance() +{ + return phys==camera1; } -bool physentreference::operator==(const worldobjreference &other) -{ - return type==other.type && phys==((physentreference &)other).phys; +bool physentreference::operator==(const worldobjreference &other) +{ + return type==other.type && phys==((physentreference &)other).phys; } // entity @@ -676,9 +676,9 @@ entityreference::entityreference(entity *ref) : worldobjreference(WR_ENTITY) ent = ref; } -worldobjreference *entityreference::clone() const -{ - return new entityreference(*this); +worldobjreference *entityreference::clone() const +{ + return new entityreference(*this); } const vec &entityreference::currentposition() const { @@ -696,36 +696,36 @@ staticreference::staticreference(const vec &ref) : worldobjreference(WR_STATICPO pos = ref; } -worldobjreference *staticreference::clone() const -{ - return new staticreference(*this); +worldobjreference *staticreference::clone() const +{ + return new staticreference(*this); } -const vec &staticreference::currentposition() const -{ - return pos; +const vec &staticreference::currentposition() const +{ + return pos; } -bool staticreference::nodistance() -{ - return false; +bool staticreference::nodistance() +{ + return false; } -bool staticreference::operator==(const worldobjreference &other) -{ - return type==other.type && pos==((staticreference &)other).pos; +bool staticreference::operator==(const worldobjreference &other) +{ + return type==other.type && pos==((staticreference &)other).pos; } // instance audiomanager audiomgr; -COMMANDF(sound, ARG_1INT, (int n) -{ - audiomgr.playsound(n); +COMMANDF(sound, ARG_1INT, (int n) +{ + audiomgr.playsound(n); }); -COMMANDF(applymapsoundchanges, ARG_NONE, (){ +COMMANDF(applymapsoundchanges, ARG_NONE, (){ audiomgr.applymapsoundchanges(); }); @@ -733,17 +733,17 @@ COMMANDF(unmuteallsounds, ARG_NONE, () { audiomgr.unmuteallsounds(); }); -COMMANDF(mutesound, ARG_2INT, (int n, int off) +COMMANDF(mutesound, ARG_2INT, (int n, int off) { audiomgr.mutesound(n, off); }); -ICOMMANDF(soundmuted, ARG_1EXP, (int n) +ICOMMANDF(soundmuted, ARG_1EXP, (int n) { return audiomgr.soundmuted(n); }); -COMMANDF(mapsoundreset, ARG_NONE, () +COMMANDF(mapsoundreset, ARG_NONE, () { audiomgr.mapsoundreset(); }); @@ -752,23 +752,23 @@ VARF(soundchannels, 4, 32, 1024, audiomgr.setchannels(soundchannels); ); VARFP(soundvol, 0, 128, 255, audiomgr.setlistenervol(soundvol); ); -COMMANDF(registersound, ARG_4STR, (char *name, char *vol, char *loop, char *audibleradius) -{ - audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius)); +COMMANDF(registersound, ARG_4STR, (char *name, char *vol, char *loop, char *audibleradius) +{ + audiomgr.addsound(name, atoi(vol), -1, atoi(loop) != 0, gamesounds, true, atoi(audibleradius)); }); -COMMANDF(mapsound, ARG_2STR, (char *name, char *maxuses) -{ - audiomgr.addsound(name, 255, atoi(maxuses), true, mapsounds, false, 0); +COMMANDF(mapsound, ARG_2STR, (char *name, char *maxuses) +{ + audiomgr.addsound(name, 255, atoi(maxuses), true, mapsounds, false, 0); }); -COMMANDF(registermusic, ARG_1STR, (char *name) -{ - audiomgr.registermusic(name); +COMMANDF(registermusic, ARG_1STR, (char *name) +{ + audiomgr.registermusic(name); }); COMMANDF(music, ARG_3STR, (char *name, char *millis, char *cmd) -{ - audiomgr.music(name, millis, cmd); +{ + audiomgr.music(name, millis, cmd); }); diff --git a/source/src/client.cpp b/source/src/client.cpp index 1eca4b54..df468765 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -260,7 +260,7 @@ void addmsg(int type, const char *fmt, ...) va_end(args); } int num = nums?0:numi, msgsize = msgsizelookup(type); - if(msgsize && num!=msgsize) { s_sprintfd(s)("inconsistent msg size for %d (%d != %d)", type, num, msgsize); fatal(s); } + if(msgsize && num!=msgsize) { fatal("inconsistent msg size for %d (%d != %d)", type, num, msgsize); } int len = p.length(); messages.add(len&0xFF); messages.add((len>>8)|(reliable ? 0x80 : 0)); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 1e7a2000..b574d01c 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -728,8 +728,7 @@ void startmap(const char *name, bool reset) // called just after a map load { loopv(gmdescs) if(gmdescs[i].mode == gamemode) { - s_sprintfd(desc)("\f1%s", gmdescs[i].desc); - conoutf(desc); + conoutf("\f1%s", gmdescs[i].desc); } } diff --git a/source/src/docs.cpp b/source/src/docs.cpp index d731f349..f7162e68 100644 --- a/source/src/docs.cpp +++ b/source/src/docs.cpp @@ -171,10 +171,10 @@ int stringsort(const char **a, const char **b) { return strcmp(*a, *b); } char *cvecstr(vector &cvec, const char *substr, int *rline = NULL) { char *r = NULL; - loopv(cvec) if(cvec[i]) if((r = strstr(cvec[i], substr)) != NULL) - { + loopv(cvec) if(cvec[i]) if((r = strstr(cvec[i], substr)) != NULL) + { if(rline) *rline = i; - break; + break; } return r; } @@ -193,8 +193,8 @@ void docundone(int allidents) srch.add(id->name); srch.add(id->desc); loopvj(id->remarks) srch.add(id->remarks[j]); - loopvj(id->arguments) - { + loopvj(id->arguments) + { srch.add(id->arguments[j].token); srch.add(id->arguments[j].desc); srch.add(id->arguments[j].values); @@ -207,7 +207,7 @@ void docundone(int allidents) } if(!cvecstr(srch, "TODO") && !cvecstr(srch, "UNDONE")) continue; } - conoutf(inames[i]); + conoutf("%s", inames[i]); } } @@ -216,10 +216,10 @@ void docinvalid() vector inames; identnames(inames, true); inames.sort(stringsort); - enumerate(docidents, docident, d, - { - if(!strchr(d.name, ' ') && !identexists(d.name)) - conoutf(d.name); + enumerate(docidents, docident, d, + { + if(!strchr(d.name, ' ') && !identexists(d.name)) + conoutf("%s", d.name); }); } @@ -231,7 +231,7 @@ void docfind(char *search) srch.add(i.name); srch.add(i.desc); loopvk(i.remarks) srch.add(i.remarks[k]); - + char *r; int rline; if((r = cvecstr(srch, search, &rline))) @@ -255,7 +255,7 @@ char *xmlstringenc(char *d, const char *s, size_t len) while(*sc && (size_t)(dc - d) < len - 1) { bool specialc = false; - loopi(sizeof(spchars)/sizeof(spchar)) if(spchars[i].c == *sc) + loopi(sizeof(spchars)/sizeof(spchar)) if(spchars[i].c == *sc) { specialc = true; size_t rlen = strlen(spchars[i].repl); @@ -279,7 +279,7 @@ void docwritebaseref(char *ref, char *schemalocation, char *transformation) if(!f) return; char desc[] = "TODO: Description"; - fprintf(f, "\n"); + fprintf(f, "\n"); fprintf(f, "\n", transformation && strlen(transformation) ? transformation : "transformations/cuberef2xhtml.xslt"); fprintf(f, "\n", ref && strlen(ref) ? ref : "Unnamed Reference", schemalocation && strlen(schemalocation) ? schemalocation : "http://cubers.net/Schemas/CubeRef schemas/cuberef.xsd"); fprintf(f, "\t%s\n", desc); @@ -287,7 +287,7 @@ void docwritebaseref(char *ref, char *schemalocation, char *transformation) fprintf(f, "\t\t
\n"); fprintf(f, "\t\t\t%s\n", desc); fprintf(f, "\t\t\t\n"); - + static const int bases[] = { ARG_1INT, ARG_1STR, ARG_1EXP, ARG_1EXPF, ARG_1EST }; string name; enumerate(*idents, ident, id, @@ -323,8 +323,8 @@ void docwritebaseref(char *ref, char *schemalocation, char *transformation) fprintf(f, "\t\t\t\t\t\n", id.minval>id.maxval ? "" : "token=\"N\"", id.minval, id.maxval, *id.storage.i, id.minval>id.maxval ? "readOnly=\"true\"" : ""); break; case ID_FVAR: - fprintf(f, "\t\t\t\t\t\n", id.minvalf>id.maxvalf ? "" : "token=\"N\"", - floatstr(id.minvalf), floatstr(id.maxvalf), floatstr(*id.storage.f), + fprintf(f, "\t\t\t\t\t\n", id.minvalf>id.maxvalf ? "" : "token=\"N\"", + floatstr(id.minvalf), floatstr(id.maxvalf), floatstr(*id.storage.f), id.minvalf>id.maxvalf ? "readOnly=\"true\"" : ""); break; } @@ -355,7 +355,7 @@ int numargs(char *args) for(char *t = args; *t; t++) { if(!argstart && *t != ' ') { argstart = t; argidx++; } - else if(argstart && *t == ' ') if(t-1 >= args) + else if(argstart && *t == ' ') if(t-1 >= args) { switch(*argstart) { @@ -399,7 +399,7 @@ void renderdoc(int x, int y, int doch) s_strcat(label, ident->arguments[j].token); } doclines.add(NULL); - + doclines.add(ident->desc); doclines.add(NULL); @@ -423,18 +423,18 @@ void renderdoc(int x, int y, int doch) } } else arg = numargs(args); - + if(arg >= 0) // multipart idents need a fixed argument offset { char *c = cmd; while((c = strchr(c, ' ')) && c++) arg--; } - + // fixes offset for var args if(arg >= ident->arguments.length() && ident->arguments.last().vararg) arg = ident->arguments.length() - 1; } - loopvj(ident->arguments) + loopvj(ident->arguments) { docargument *a = &ident->arguments[j]; if(!a) continue; @@ -452,7 +452,7 @@ void renderdoc(int x, int y, int doch) } if(ident->examples.length()) // examples - { + { doclines.add(ident->examples.length() == 1 ? "Example:" : "Examples:"); loopvj(ident->examples) { @@ -505,7 +505,7 @@ void renderdoc(int x, int y, int doch) if(cury + height > doch) break; cury += height; maxl = j+1; - } + } if(offset > 0 && maxl >= doclines.length()) { for(int j = offset-1; j >= 0; j--) @@ -520,7 +520,7 @@ void renderdoc(int x, int y, int doch) } - cury = y; + cury = y; for(int j = offset; j < maxl; j++) { const char *str = doclines[j]; @@ -558,7 +558,7 @@ void renderdocsection(void *menu, bool init) { static vector msections; msections.setsize(0); - + loopv(sections) { if(sections[i].menu != menu) continue; diff --git a/source/src/server.cpp b/source/src/server.cpp index c2aa884f..b4929595 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -3156,7 +3156,7 @@ void process(ENetPacket *packet, int sender, int chan) // sender may be -1 getstring(text, p, n); if(valid_client(sender) && clients[sender]->role==CR_ADMIN && logger) - logger->writeline(log::info, text); + logger->writeline(log::info, "%s", text); } // else if() @@ -3619,7 +3619,7 @@ void fatal(const char *s, ...) cleanupserver(); s_sprintfdlv(msg,s,s); s_sprintfd(out)("AssaultCube fatal error: %s", msg); - if(logger) logger->writeline(log::error, out); + if(logger) logger->writeline(log::error, "%s", out); else puts(out); exit(EXIT_FAILURE); } diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 82931202..591d534d 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -374,7 +374,7 @@ void stackdumper(unsigned int type, EXCEPTION_POINTERS *ep) s_strcat(out, t); } } - fatal(out); + fatal("%s", out); } #elif defined(linux) || defined(__linux) || defined(__linux__)