From 3d4ac8859077819070ab0bc96cea9d3af86f0661 Mon Sep 17 00:00:00 2001 From: terminx Date: Tue, 18 Apr 2006 19:23:53 +0000 Subject: [PATCH] This is better git-svn-id: https://svn.eduke32.com/eduke32@59 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/source/funct.h | 2 +- polymer/eduke32/source/game.c | 55 ++++++++++++++++++- polymer/eduke32/source/menus.c | 93 ++++++++------------------------ polymer/eduke32/source/osdcmds.c | 6 ++- polymer/eduke32/source/player.c | 4 +- 5 files changed, 83 insertions(+), 77 deletions(-) diff --git a/polymer/eduke32/source/funct.h b/polymer/eduke32/source/funct.h index dfed7c352..772d775cf 100644 --- a/polymer/eduke32/source/funct.h +++ b/polymer/eduke32/source/funct.h @@ -351,5 +351,5 @@ extern void OnEvent(int iEventID, short sActor,short sPlayer,long lDist); extern int isspritemakingsound(short i, int num); extern int issoundplaying(int num); extern void stopspritesound(short num, short i); - +extern void updatenames(void); #endif // __funct_h__ diff --git a/polymer/eduke32/source/game.c b/polymer/eduke32/source/game.c index 4c20f796f..7adb19b17 100644 --- a/polymer/eduke32/source/game.c +++ b/polymer/eduke32/source/game.c @@ -8122,7 +8122,7 @@ void getnames(void) buf[l++] = ps[myconnectindex].aim_mode = ud.mouseaiming; buf[l++] = ps[myconnectindex].auto_aim = AutoAim; buf[l++] = ps[myconnectindex].weaponswitch = ud.weaponswitch; - buf[l++] = ud.pcolor[myconnectindex] = ud.color; + buf[l++] = ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = ud.color; for(i=connecthead;i>=0;i=connectpoint2[i]) { @@ -8139,6 +8139,57 @@ void getnames(void) gameexit("Please put the Duke Nukem 3D Atomic Edition CD in the CD-ROM drive."); } +void updatenames(void) +{ + int i,l; + + if(ud.multimode > 1) + { + // send update + for(l=0;l=0;i=connectpoint2[i]) + { + if (i != myconnectindex) sendpacket(i,&buf[0],l); + if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master + } + } + else + { + ps[myconnectindex].aim_mode = ud.mouseaiming; + ps[myconnectindex].auto_aim = AutoAim; + ps[myconnectindex].weaponswitch = ud.weaponswitch; + ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = ud.color; + + if(sprite[ps[myconnectindex].i].picnum == APLAYER) + sprite[ps[myconnectindex].i].pal = ud.color; + } +} + void writestring(long a1,long a2,long a3,short a4,long vx,long vy,long vz) { @@ -8455,7 +8506,7 @@ MAIN_LOOP_RESTART: ps[myconnectindex].aim_mode = ud.mouseaiming; ps[myconnectindex].auto_aim = AutoAim; ps[myconnectindex].weaponswitch = ud.weaponswitch; - ud.pcolor[myconnectindex] = ud.color; + ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = ud.color; ud.warp_on = 0; KB_KeyDown[sc_Pause] = 0; // JBF: I hate the pause key diff --git a/polymer/eduke32/source/menus.c b/polymer/eduke32/source/menus.c index cf91032ea..b76c4a2f7 100644 --- a/polymer/eduke32/source/menus.c +++ b/polymer/eduke32/source/menus.c @@ -494,6 +494,20 @@ int getfilenames(char *path, char kind[]) long quittimer = 0; +void check_player_color(int *color,int prev_color) +{ + int i, disallowed[] = { 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 22 }; + + for(i=0;i<(signed)(sizeof(disallowed)/sizeof(disallowed[0]));i++) { + if(*color == disallowed[i]) { + if(*color > prev_color) + (*color)++; + else (*color)--; + i=0; + } + } +} + void menus(void) { CACHE1D_FIND_REC *dir; @@ -621,73 +635,25 @@ void menus(void) ud.color++; if(ud.color > 22) ud.color = 0; - goto check_player_color; + check_player_color((int *)&ud.color,-1); + updatenames(); break; case 2: AutoAim = (AutoAim == 2) ? 0 : AutoAim+1; - goto player_menu_update; + updatenames(); break; case 3: ud.weaponswitch = (ud.weaponswitch == 3) ? 0 : ud.weaponswitch+1; - goto player_menu_update; - break; - - case 4: -player_menu_update: - if(ud.multimode > 1) - { - // send update - for(l=0;myname[l];l++) - ud.user_name[myconnectindex][l] = Btoupper(myname[l]); - - buf[0] = 6; - buf[1] = myconnectindex; - buf[2] = BYTEVERSION; - l = 3; - - //null terminated player name to send - for(i=0;myname[i];i++) buf[l++] = Btoupper(myname[i]); - buf[l++] = 0; - - for(i=0;i<10;i++) - { - ud.wchoice[myconnectindex][i] = ud.wchoice[0][i]; - buf[l++] = (char)ud.wchoice[0][i]; - } - - buf[l++] = ps[myconnectindex].aim_mode = ud.mouseaiming; - buf[l++] = ps[myconnectindex].auto_aim = AutoAim; - buf[l++] = ps[myconnectindex].weaponswitch = ud.weaponswitch; - - buf[l++] = ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = ud.color; - if(sprite[ps[myconnectindex].i].picnum == APLAYER) - sprite[ps[myconnectindex].i].pal = ud.color; - - for(i=connecthead;i>=0;i=connectpoint2[i]) - { - if (i != myconnectindex) sendpacket(i,&buf[0],l); - if ((!networkmode) && (myconnectindex != connecthead)) break; //slaves in M/S mode only send to master - } - } - else - { - ps[myconnectindex].aim_mode = ud.mouseaiming; - ps[myconnectindex].auto_aim = AutoAim; - ps[myconnectindex].weaponswitch = ud.weaponswitch; - - ps[myconnectindex].palookup = ud.pcolor[myconnectindex] = ud.color; - if(sprite[ps[myconnectindex].i].picnum == APLAYER) - sprite[ps[myconnectindex].i].pal = ud.color; - } + updatenames(); break; } } else { x = strget(200,50-9,buf,12,0); if (x) { if (x == 1) { - strcpy(myname,buf); + Bstrcpy(myname,buf); // send name update } KB_ClearKeyDown(sc_Enter); @@ -695,7 +661,7 @@ player_menu_update: KB_FlushKeyboardQueue(); current_menu = 20002; - goto player_menu_update; + updatenames(); } } @@ -711,22 +677,9 @@ player_menu_update: modval(0,23,(int *)&ud.color,1,probey==1); modval(0,2,(int *)&AutoAim,1,probey==2); modval(0,3,(int *)&ud.weaponswitch,1,probey==3); - -check_player_color: - { - int i, disallowed[] = { 1, 2, 3, 4, 5, 6, 7, 8, 17, 18, 19, 20, 22 }; - - for(i=0;i<(signed)(sizeof(disallowed)/sizeof(disallowed[0]));i++) { - if(ud.color == disallowed[i]) { - if(ud.color > ud_color) - ud.color++; - else ud.color--; - i=0; - } - } - if(ud_color != ud.color || aaim != AutoAim || ud_weaponswitch != ud.weaponswitch) - goto player_menu_update; - } + check_player_color((int *)&ud.color,ud_color); + if(ud_color != ud.color || aaim != AutoAim || ud_weaponswitch != ud.weaponswitch) + updatenames(); } menutext(40,50+20+20,0,0,"AUTO AIM"); menutext(40,50+20+20+20,0,0,"WEAPON SWITCH"); diff --git a/polymer/eduke32/source/osdcmds.c b/polymer/eduke32/source/osdcmds.c index c9a405758..1cb487210 100644 --- a/polymer/eduke32/source/osdcmds.c +++ b/polymer/eduke32/source/osdcmds.c @@ -434,7 +434,7 @@ struct cvarmappings { char *name; char *helpstr; void *var; - int type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer + int type; // 0 = integer, 1 = unsigned integer, 2 = boolean, 3 = string, |128 = not in multiplayer, |256 = update multi int extra; // for string, is the length } cvar[] = { @@ -442,7 +442,7 @@ struct cvarmappings { { "showcoords", "showcoords: show your position in the game world", (void*)&ud.coords, CVAR_BOOL, 0 }, { "useprecache", "useprecache: enable/disable the pre-level caching routine", (void*)&useprecache, CVAR_BOOL, 0 }, { "drawweapon", "drawweapon: enable/disable weapon drawing", (void*)&ud.drawweapon, CVAR_INT, 0 }, - { "name", "name: change your multiplayer nickname", (void*)&myname[0], CVAR_STRING|128, sizeof(myname) } + { "name", "name: change your multiplayer nickname", (void*)&myname[0], CVAR_STRING|256, sizeof(myname) } }; int osdcmd_cvar_set(const osdfuncparm_t *parm) @@ -486,6 +486,8 @@ int osdcmd_cvar_set(const osdfuncparm_t *parm) } break; default: break; } + if(cvar[i].type&256) + updatenames(); } } OSD_Printf("\n"); diff --git a/polymer/eduke32/source/player.c b/polymer/eduke32/source/player.c index d058debad..fcb6320c9 100644 --- a/polymer/eduke32/source/player.c +++ b/polymer/eduke32/source/player.c @@ -2979,8 +2979,6 @@ char doincrements(struct player_struct *p) // j = sync[snum].avel; // p->weapon_ang = -(j/5); - p->player_par++; - if(p->invdisptime > 0) p->invdisptime--; @@ -3207,6 +3205,8 @@ void processinput(short snum) kb = &p->kickback_pic; + p->player_par++; + OnEvent(EVENT_PROCESSINPUT, pi, snum, -1); if(p->cheat_phase <= 0) sb_snum = sync[snum].bits;