bug fixes/enhancements: findsens, scripts, "gospectate", clean up and bug fix update 1.1.0.2 (do not revert this)

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5600 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-08-11 21:07:48 +00:00
parent f031b44653
commit b01dc4eddc
8 changed files with 264 additions and 210 deletions
+1 -1
View File
@@ -54,7 +54,7 @@ menuitem "" -1
menuitemtextinput "Nickname: " "result $curname" "name $arg1"
menuitem "Change weapon..." "showmenu Weapons" [__ingamemenu_showmodel "In-game admin" 0]
menuitem "Change to the enemy team" "changeteam" [__ingamemenu_showmodel "In-game admin" 1]
menuitem "Change to spectate mode" "gospectate" [__ingamemenu_showmodel "In-game admin" 1]
menuitem "Change to spectate mode" "spectate" [__ingamemenu_showmodel "In-game admin" 1]
menuitem "Change player skin..." [showmenu (at [CLA RVSF] (curteam))] [__ingamemenu_showmodel "In-game admin" 1]
menuitem "Demos..." "showmenu Demo" [__ingamemenu_showmodel "In-game admin" 0]
menuitem "" -1
+8
View File
@@ -624,6 +624,14 @@
e.g. <span class="code">-D5</span>
</td>
</tr>
<tr>
<td style="text-align: center;vertical-align: top">
<span class="codecommandline">-D</span>I
</td>
<td>
Limit the demo downloading to intermission (it doubles the intermission time if someone is downloading a demo).
</td>
</tr>
<tr>
<td style="text-align: center;vertical-align: top">
<span class="codecommandline">-W</span>f
+10
View File
@@ -701,6 +701,16 @@ void exec(const char *cfgfile)
if(!execfile(cfgfile)) conoutf("could not read \"%s\"", cfgfile);
}
void execdir(const char *dir)
{
vector<char *> files;
listfiles(dir, "cfg", files);
loopv(files) {
defformatstring(d)("%s/%s.cfg",dir,files[i]);
exec(d);
}
}
COMMAND(execdir,ARG_1STR);
// below the commands that implement a small imperative language. thanks to the semantics of
// () and [] expressions, any control construct can be defined trivially.
+1 -1
View File
@@ -52,7 +52,7 @@ extern int verbose;
#include "protos.h" // external function decls
#define AC_VERSION 1101
#define AC_VERSION 1102
#define AC_MASTER_URI "assault.cubers.net"
#define AC_MASTER_PORT 28760
#define MAXCL 20
+153 -153
View File
@@ -739,7 +739,7 @@ void checkinput()
{
if (event.key.state==SDL_PRESSED)
{
extern void tsens(int x);
extern int tsens(int x);
tsens(event.key.keysym.sym);
}
}
@@ -876,212 +876,212 @@ int main(int argc, char **argv)
else conoutf("\f3unknown commandline argument: %c", argv[i][0]);
}
}
if(quitdirectly) return EXIT_SUCCESS;
if(quitdirectly) return EXIT_SUCCESS;
i18nmanager i18n("AC", path("packages/locale", true));
i18nmanager i18n("AC", path("packages/locale", true));
initing = NOT_INITING;
initing = NOT_INITING;
initlog("sdl");
int par = 0;
#ifdef _DEBUG
par = SDL_INIT_NOPARACHUTE;
#endif
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|par)<0) fatal("Unable to initialize SDL");
initlog("sdl");
int par = 0;
#ifdef _DEBUG
par = SDL_INIT_NOPARACHUTE;
#endif
if(SDL_Init(SDL_INIT_TIMER|SDL_INIT_VIDEO|par)<0) fatal("Unable to initialize SDL");
#if 0
if(highprocesspriority) setprocesspriority(true);
#endif
#if 0
if(highprocesspriority) setprocesspriority(true);
#endif
if (!dedicated) initlog("net");
if(enet_initialize()<0) fatal("Unable to initialise network module");
if (!dedicated) initlog("net");
if(enet_initialize()<0) fatal("Unable to initialise network module");
if (!dedicated) initclient();
if (!dedicated) initclient();
//FIXME the server executed in this way does not catch the SIGTERM or ^C
initserver(dedicated,argc,argv); // never returns if dedicated
initserver(dedicated,argc,argv); // never returns if dedicated
initlog("world");
empty_world(7, true);
initlog("world");
empty_world(7, true);
initlog("video: sdl");
if(SDL_InitSubSystem(SDL_INIT_VIDEO)<0) fatal("Unable to initialize SDL Video");
initlog("video: sdl");
if(SDL_InitSubSystem(SDL_INIT_VIDEO)<0) fatal("Unable to initialize SDL Video");
initlog("video: mode");
int usedcolorbits = 0, useddepthbits = 0, usedfsaa = 0;
setupscreen(usedcolorbits, useddepthbits, usedfsaa);
initlog("video: mode");
int usedcolorbits = 0, useddepthbits = 0, usedfsaa = 0;
setupscreen(usedcolorbits, useddepthbits, usedfsaa);
// no more TTF ATM.
//initlog("font");
//initfont();
//initlog("font");
//initfont();
initlog("video: misc");
SDL_WM_SetCaption("AssaultCube", NULL);
keyrepeat(false);
SDL_ShowCursor(0);
initlog("video: misc");
SDL_WM_SetCaption("AssaultCube", NULL);
keyrepeat(false);
SDL_ShowCursor(0);
initlog("gl");
gl_checkextensions();
gl_init(scr_w, scr_h, usedcolorbits, useddepthbits, usedfsaa);
initlog("gl");
gl_checkextensions();
gl_init(scr_w, scr_h, usedcolorbits, useddepthbits, usedfsaa);
notexture = noworldtexture = textureload("packages/misc/notexture.jpg");
if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
notexture = noworldtexture = textureload("packages/misc/notexture.jpg");
if(!notexture) fatal("could not find core textures (hint: run AssaultCube from the parent of the bin directory)");
initlog("console");
persistidents = false;
if(!execfile("config/font.cfg")) fatal("cannot find default font definitions");
if(!execfile("config/mono.cfg")) fatal("cannot find default font definitions");
if(!setfont("mono")) fatal("no mono font specified");
if(!setfont("default")) fatal("no default font specified");
initlog("console");
persistidents = false;
if(!execfile("config/font.cfg")) fatal("cannot find default font definitions");
if(!execfile("config/mono.cfg")) fatal("cannot find default font definitions");
if(!setfont("mono")) fatal("no mono font specified");
if(!setfont("default")) fatal("no default font specified");
loadingscreen();
loadingscreen();
particleinit();
particleinit();
initlog("sound");
audiomgr.initsound();
initlog("sound");
audiomgr.initsound();
initlog("cfg");
extern void *scoremenu, *teammenu, *ctfmenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu;
initlog("cfg");
extern void *scoremenu, *teammenu, *ctfmenu, *servmenu, *searchmenu, *serverinfomenu, *kickmenu, *banmenu, *forceteammenu, *giveadminmenu, *docmenu, *applymenu;
scoremenu = addmenu("score", "columns", false, renderscores, NULL, false, true);
teammenu = addmenu("team score", "columns", false, renderscores, NULL, false, true);
ctfmenu = addmenu("ctf score", "columns", false, renderscores, NULL, false, true);
reorderscorecolumns();
servmenu = addmenu("server", NULL, true, refreshservers, serverskey);
searchmenu = addmenu("search", NULL, true, refreshservers, serverskey);
serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey);
kickmenu = addmenu("kick player", NULL, true, refreshsopmenu);
banmenu = addmenu("ban player", NULL, true, refreshsopmenu);
forceteammenu = addmenu("force team", NULL, true, refreshsopmenu);
giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu);
docmenu = addmenu("reference", NULL, true, renderdocmenu);
applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu);
servmenu = addmenu("server", NULL, true, refreshservers, serverskey);
searchmenu = addmenu("search", NULL, true, refreshservers, serverskey);
serverinfomenu = addmenu("serverinfo", NULL, true, refreshservers, serverinfokey);
kickmenu = addmenu("kick player", NULL, true, refreshsopmenu);
banmenu = addmenu("ban player", NULL, true, refreshsopmenu);
forceteammenu = addmenu("force team", NULL, true, refreshsopmenu);
giveadminmenu = addmenu("give admin", NULL, true, refreshsopmenu);
docmenu = addmenu("reference", NULL, true, renderdocmenu);
applymenu = addmenu("apply", "apply changes now?", true, refreshapplymenu);
exec("config/scontext.cfg");
exec("config/locale.cfg");
exec("config/keymap.cfg");
exec("config/menus.cfg");
exec("config/scripts.cfg");
exec("config/prefabs.cfg");
exec("config/sounds.cfg");
exec("config/securemaps.cfg");
exec("config/admin.cfg");
execfile("config/servers.cfg");
persistidents = true;
exec("config/scontext.cfg");
exec("config/locale.cfg");
exec("config/keymap.cfg");
exec("config/menus.cfg");
exec("config/scripts.cfg");
exec("config/prefabs.cfg");
exec("config/sounds.cfg");
exec("config/securemaps.cfg");
exec("config/admin.cfg");
execfile("config/servers.cfg");
persistidents = true;
static char resdata[] = { 112, 97, 99, 107, 97, 103, 101, 115, 47, 116, 101, 120, 116, 117, 114, 101, 115, 47, 107, 117, 114, 116, 47, 107, 108, 105, 116, 101, 50, 46, 106, 112, 103, 0 };
stream *f = opengzfile(resdata, "rb");
if(f)
{
int n = f->getlil<int>();
loopi(n)
{
string s;
f->read(s, sizeof(string));
enet_uint32 c = f->getlil<enet_uint32>();
setresdata(s, c);
}
static char resdata[] = { 112, 97, 99, 107, 97, 103, 101, 115, 47, 116, 101, 120, 116, 117, 114, 101, 115, 47, 107, 117, 114, 116, 47, 107, 108, 105, 116, 101, 50, 46, 106, 112, 103, 0 };
stream *f = opengzfile(resdata, "rb");
if(f)
{
int n = f->getlil<int>();
loopi(n)
{
string s;
f->read(s, sizeof(string));
enet_uint32 c = f->getlil<enet_uint32>();
setresdata(s, c);
}
delete f;
}
}
initing = INIT_LOAD;
if(!execfile("config/saved.cfg"))
{
exec("config/defaults.cfg");
firstrun = true;
}
execfile("config/autoexec.cfg");
execute("addallfavcatmenus"); // exec here, to add all categories (including those defined in autoexec.cfg)
initing = NOT_INITING;
initing = INIT_LOAD;
if(!execfile("config/saved.cfg"))
{
exec("config/defaults.cfg");
firstrun = true;
}
execfile("config/autoexec.cfg");
execute("addallfavcatmenus"); // exec here, to add all categories (including those defined in autoexec.cfg)
initing = NOT_INITING;
initlog("models");
preload_playermodels();
preload_hudguns();
preload_entmodels();
initlog("models");
preload_playermodels();
preload_hudguns();
preload_entmodels();
initlog("docs");
persistidents = false;
execfile("config/docs.cfg");
persistidents = true;
initlog("docs");
persistidents = false;
execfile("config/docs.cfg");
persistidents = true;
initlog("localconnect");
extern string clientmap;
initlog("localconnect");
extern string clientmap;
if(initdemo)
{
extern int gamemode;
gamemode = -1;
copystring(clientmap, initdemo);
}
else
copystring(clientmap, initmap); // ac_complex for 1.0, ac_shine for 1.1, ..
if(initdemo)
{
extern int gamemode;
gamemode = -1;
copystring(clientmap, initdemo);
}
else
copystring(clientmap, initmap); // ac_complex for 1.0, ac_shine for 1.1, ..
localconnect();
localconnect();
if(initscript) execute(initscript);
if(initscript) execute(initscript);
initlog("mainloop");
initlog("mainloop");
inputgrab(grabinput = true);
inputgrab(grabinput = true);
inmainloop = true;
inmainloop = true;
#ifdef _DEBUG
int lastflush = 0;
int lastflush = 0;
#endif
for(;;)
{
static int frames = 0;
static float fps = 10.0f;
int millis = SDL_GetTicks() - clockrealbase;
if(clockfix) millis = int(millis*(double(clockerror)/1000000));
millis += clockvirtbase;
if(millis<totalmillis) millis = totalmillis;
limitfps(millis, totalmillis);
int elapsed = millis-totalmillis;
if(multiplayer(false)) curtime = elapsed;
else
{
static int timeerr = 0;
int scaledtime = elapsed*gamespeed + timeerr;
curtime = scaledtime/100;
timeerr = scaledtime%100;
if(paused) curtime = 0;
}
lastmillis += curtime;
totalmillis = millis;
for(;;)
{
static int frames = 0;
static float fps = 10.0f;
int millis = SDL_GetTicks() - clockrealbase;
if(clockfix) millis = int(millis*(double(clockerror)/1000000));
millis += clockvirtbase;
if(millis<totalmillis) millis = totalmillis;
limitfps(millis, totalmillis);
int elapsed = millis-totalmillis;
if(multiplayer(false)) curtime = elapsed;
else
{
static int timeerr = 0;
int scaledtime = elapsed*gamespeed + timeerr;
curtime = scaledtime/100;
timeerr = scaledtime%100;
if(paused) curtime = 0;
}
lastmillis += curtime;
totalmillis = millis;
checkinput();
checkinput();
if(lastmillis) updateworld(curtime, lastmillis);
if(lastmillis) updateworld(curtime, lastmillis);
if(needsautoscreenshot) showscores(true);
if(needsautoscreenshot) showscores(true);
serverslice(0);
serverslice(0);
if(elapsed) fps = (1000.0f/elapsed+fps*10)/11; // avoid DIV-by-0
frames++;
if(elapsed) fps = (1000.0f/elapsed+fps*10)/11; // avoid DIV-by-0
frames++;
audiomgr.updateaudio();
audiomgr.updateaudio();
computeraytable(camera1->o.x, camera1->o.y, dynfov());
if(frames>3 && !minimized)
{
gl_drawframe(screen->w, screen->h, fps<lowfps ? fps/lowfps : (fps>highfps ? fps/highfps : 1.0f), fps);
if(frames>4) SDL_GL_SwapBuffers();
}
computeraytable(camera1->o.x, camera1->o.y, dynfov());
if(frames>3 && !minimized)
{
gl_drawframe(screen->w, screen->h, fps<lowfps ? fps/lowfps : (fps>highfps ? fps/highfps : 1.0f), fps);
if(frames>4) SDL_GL_SwapBuffers();
}
if(needsautoscreenshot) makeautoscreenshot();
if(needsautoscreenshot) makeautoscreenshot();
#ifdef _DEBUG
if(millis>lastflush+60000) { fflush(stdout); lastflush = millis; }
if(millis>lastflush+60000) { fflush(stdout); lastflush = millis; }
#endif
}
}
quit();
quit();
return EXIT_SUCCESS;
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
#if defined(WIN32) && !defined(_DEBUG) && !defined(__GNUC__)
} __except(stackdumper(0, GetExceptionInformation()), EXCEPTION_CONTINUE_SEARCH) { return 0; }
#endif
#endif
}
VAR(version, 1, AC_VERSION, 0);
+81 -48
View File
@@ -760,65 +760,95 @@ VARP(invmouse, 0, 0, 1);
FVARP(mouseaccel, 0, 0, 1000);
FVARP(mfilter, 0.0f, 0.0f, 6.0f);
VARP(autoscopesens, 0, 0, 1);
float fdx = 0, fdy = 0;
float testsens=0;
bool senst=0;
void tsens(int x)
int tsens(int x)
{
static bool highlock=0,lowlock=0;
static bool hightry=0,lowtry=0;
static float sensn=0,sensl=0,sensh=0;
static int nstep=1;
if (x==-2000) { // RENDERING PART!!!
if(senst) {
draw_textf(
"\fJSensitivity Training (hotkeys):\n\fE1. try High Sens. %s\n2. try Low Sens. %s\n\fJ%s :"
"\fE\n3. choose: High Sens.\n4. choose: Low Sens.\n\fIrepeat the steps above until the training stops.\n\f35. Stop Training.",
VIRTW/4 , VIRTH/3,
hightry?"(TRYED)":"" , lowtry?"(TRYED)":"",
hightry&&lowtry?"after trying both choose the one you liked most":"now you can choose the sensitivity you preferred");
glPushMatrix(); glScalef(2,2,2);
draw_textf("step: \f0%d",VIRTW/2 , VIRTH/3*2,nstep);
glPopMatrix();
}
return 0;
}
if (x == SDLK_3 || x == SDLK_4)
{
if (x == SDLK_3) //high sens
{
lowlock=1;
if (highlock)
{
sensl=sensn;
sensn=(sensh+sensl)/2.0f;
if(!hightry || !lowtry) {
if(!hightry && !lowtry) {
conoutf("--- \f3ERROR:\f0before choosing a sensitivity, first try both higher and lower sens.");
} else {
conoutf("--- \f3ERROR:\f0try the %s%ser sensitivity too.",hightry?"":"high",lowtry?"":"low");
}
else
} else {
if (x == SDLK_3) //high sens
{
sensl=sensn;
sensn=sensh;
sensh=sensn*2.0f;
lowlock=1;
if (highlock)
{
sensl=sensn;
sensn=(sensh+sensl)/2.0f;
}
else
{
sensl=sensn;
sensn=sensh;
sensh=sensn*2.0f;
}
}
if (x == SDLK_4) //low sens
{
highlock=1;
if (lowlock)
{
sensh=sensn;
sensn=(sensh+sensl)/2.0f;
}
else
{
sensh=sensn;
sensn=sensl;
sensl=sensn/2.0f;
}
}
if(sensh/sensn > 1.04f) {
conoutf("--- \f0you choose: the %ser sensitivity.",x==SDLK_3?"higher":"lower");
conoutf("--- \f0repeat previous steps by trying both higher and lower sens and then by choosing the one you like most.");
hudoutf("next step!");
nstep++;
}
testsens=sensn;
hightry=lowtry=0;
}
if (x == SDLK_4) //low sens
{
highlock=1;
if (lowlock)
{
sensh=sensn;
sensn=(sensh+sensl)/2.0f;
}
else
{
sensh=sensn;
sensn=sensl;
sensl=sensn/2.0f;
}
}
conoutf("--- \f0you choose: the %s sens",x==SDLK_3?"higher":"lower");
testsens=sensn;
}
if (x == SDLK_2)
{
testsens=sensl;
conoutf("--- \f0You are now trying the lower sens.");
conoutf("--- \f0You are now %strying the lower sensitivity.",lowtry?"re-":""); lowtry=1;
}
if (x == SDLK_1)
{
testsens=sensh;
conoutf("--- \f0You are now trying the higher sens.");
conoutf("--- \f0You are now %strying the higher sensitivity.",hightry?"re-":""); hightry=1;
}
if (x==-1000)
{
sensh=sensitivity*2.0f;
sensl=sensitivity/2.0f;
sensn=sensitivity;
float factor=rnd(800)+600;
factor/=1000;
sensh=sensitivity*factor*2.0f;
sensl=sensitivity*factor/2.0f;
sensn=sensitivity*factor;
}
if (sensh/sensn <= 1.04f || x == SDLK_5)
{
@@ -829,17 +859,22 @@ void tsens(int x)
} else {
conoutf("--- \f0Sensitivity Training Stopped.");
}
highlock=lowlock=0;
hightry=lowtry=highlock=lowlock=0;
sensn=sensl=sensh=0;
testsens=0;
nstep=1;
}
return 0;
}
void findsens()
{
senst=1;
tsens(-1000);
testsens=sensitivity;
conoutf("--- \f0Sensitivity Training Started.");
if(!watchingdemo) {
senst=1;
tsens(-1000);
testsens=sensitivity;
conoutf("--- \f0Sensitivity Training Started.");
return;
}
}
COMMAND(findsens,ARG_NONE);
@@ -848,9 +883,8 @@ inline bool zooming(playerent *plx) { return (plx->weaponsel->type == GUN_SNIPER
void mousemove(int odx, int ody)
{
if(intermission) return;
if(player1->isspectating() && player1->spectatemode==SM_FOLLOW1ST) return;
static float fdx = 0, fdy = 0;
if(intermission || (player1->isspectating() && player1->spectatemode==SM_FOLLOW1ST)) return;
float dx = odx, dy = ody;
if(mfilter > 0.0f)
{
@@ -858,7 +892,6 @@ void mousemove(int odx, int ody)
dx = fdx = dx * ( 1.0f - k ) + fdx * k;
dy = fdy = dy * ( 1.0f - k ) + fdy * k;
}
float cursens = sensitivity;
if(senst) {cursens=testsens;}
if(mouseaccel && curtime && (dx || dy)) cursens += 0.02f * mouseaccel * sqrtf(dx*dx + dy*dy)/curtime;
@@ -866,8 +899,8 @@ void mousemove(int odx, int ody)
if( zooming(player1) )
{
extern float fov; extern int scopefov;
cursens *= autoscopesens ? ((float)scopefov*0.66f/fov) : scopesensscale;
extern float scopesensfunc;
cursens *= autoscopesens ? scopesensfunc : scopesensscale;
}
camera1->yaw += dx*cursens;
+8 -3
View File
@@ -419,10 +419,15 @@ void fixresizedscreen()
#endif
}
FVARP(fov, 75, 90, 120);
VARP(scopefov, 5, 50, 60);
float scopesensfunc = 0.4663077f
void scopefunc();
FVARFP(fov, 75, 90, 120, scopefunc());
VARFP(scopefov, 5, 50, 60, scopefunc());
VARP(spectfov, 5, 110, 120);
void scopefunc()
{
scopesensfunc = tan(((float)scopefov)*0.5f*RAD)/tan(fov*0.5f*RAD);
}
// map old fov values to new ones
void fovcompat(int oldfov)
+2 -4
View File
@@ -766,10 +766,8 @@ void gl_drawhud(int w, int h, int curfps, int nquads, int curvert, bool underwat
glLoadIdentity();
glOrtho(0, VIRTW*2, VIRTH*2, 0, -1, 1);
extern bool senst;
if(senst) {
draw_textf("\fJSensitivity Training (hotkeys):\n\fE1. try High Sens.\n2. try Low Sens.\n\fJafter trying both choose the one you liked most:\fE\n3. choose: High Sens.\n4. choose: Low Sens.\n\fIrepeat the steps above until the training stops.\n\f35. Stop Training.", VIRTW/4, VIRTH/3);
}
extern int tsens(int x);
tsens(-2000);
if(!hideconsole) renderconsole();
if(showstats)