ref: ed82668431413cf8d5389a631cad56a6c4d2d6da
parent: 9e8fb5bd060cfe44303744978ceab8ab23ee5ae6
author: Konstantinn Bonnet <[email protected]>
date: Tue Jun 2 22:56:38 EDT 2015
misc fixes and cleanup - fix/implement Sys_ConsoleInput, NET_Sleep, NET_AdrToString - nuke Q_strcasecmp et al - remove some redundant definitions of variables, move some where they belong - fix CL_Setenv_f (is this function useful for anything anyway?) - minor cleanups
--- a/README
+++ b/README
@@ -1,28 +1,35 @@
qk2 - (9) quake 2
=================
- - game data dirs are stored in $home/lib/quake2/, e.g. $home/lib/quake2/dicks/
- - 386 and amd64 only
+ - installation
+ . mk install
+ . mkdir -p $home/lib/quake2/baseq2
+ . dircp /n/quake2cd/baseq2 $home/lib/quake2/baseq2
+ - game dir for gamemode "dicks" is stored in $home/lib/quake2/dicks/
+ - tested on 386 and amd64 only
-
horrors
-------
- - #pragma pack on set globally!!!
- - rendering glitches and fault reads on resolutions not originally supported
- (4:3 and SXGA)
+ - rendering glitches and fault reads on resolutions not originally
+ supported (anything other than 4:3)
- edict_t definitions merged without much looking
- - q_sh9: stupid posixish glob stuff
- - net_udp mostly horrid
+ - plan9/misc.c: stupid posixish glob stuff
+ - plan9/udp.c mostly horrid
- portme: cd_9
- garbled stdout (Sys_ConsoleOutput): \r instead of \n
- - dedicated 1: input not working (Sys_ConsoleInput)
- - race between mproc and IN_Commands
- cinematic palette is fucked up if you resize during playback
- - sound only works thanks to shitty workarounds
- - bad/unsafe rename() implementation
+ - sound only (sortof) works thanks to shitty workarounds
- ctf is untouched, so are rogue, xatrix
+differences with linux/x11 quake2
+---------------------------------
+ - mouse wheel up and down recognized and useable (but parsing is ugly)
+ - mouse buttons have (correct) plan9 names
+ - arbitrary resolutions up to 4096x4096 allowed (ref/r_local.h) and
+ resize by dragging window edges
+ - no dynamic linking → "modules" are statically linked
legal
-----
Quake 2, hence qk2, is licensed under the GPLv2. See COPYING for details.
-All of the Q2 data files remain copyrighted and licensed under the original terms.
+All of the Q2 data files remain copyrighted and licensed under the original
+terms.
--- a/client/cl_input.c
+++ b/client/cl_input.c
@@ -26,7 +26,6 @@
cvar_t *cl_nodelta;
-extern unsigned sys_frame_time;
unsigned frame_msec;
unsigned old_sys_frame_time;
--- a/client/cl_inv.c
+++ b/client/cl_inv.c
@@ -120,7 +120,7 @@
Com_sprintf (binding, sizeof(binding), "use %s", cl.configstrings[CS_ITEMS+item]);
bind = "";
for (j=0 ; j<256 ; j++)
- if (keybindings[j] && !Q_strcasecmp (keybindings[j], binding))
+ if (keybindings[j] && !cistrcmp (keybindings[j], binding))
{
bind = Key_KeynumToString(j);
break;
--- a/client/cl_main.c
+++ b/client/cl_main.c
@@ -24,8 +24,6 @@
#include <stdio.h>
#include "../q_shared.h"
-cvar_t *freelook;
-
cvar_t *adr0;
cvar_t *adr1;
cvar_t *adr2;
@@ -63,15 +61,6 @@
cvar_t *cl_paused;
cvar_t *cl_timedemo;
-cvar_t *lookspring;
-cvar_t *lookstrafe;
-cvar_t *sensitivity;
-
-cvar_t *m_pitch;
-cvar_t *m_yaw;
-cvar_t *m_forward;
-cvar_t *m_side;
-
cvar_t *cl_lightlevel;
//
@@ -304,37 +293,31 @@
}
}
-void CL_Setenv_f( void )
+void
+CL_Setenv_f(void)
{
int i, l = 0, argc;
- char name[1024], val[1024] = {0}, *env;
+ char name[1024], val[1024], *env;
argc = Cmd_Argc();
- if (argc > 2)
- {
+ if(argc > 2){
strncpy(name, Cmd_Argv(1), sizeof name);
- for (i = 2; i < argc; i++)
- {
- strncpy (val+l, Cmd_Argv(i), sizeof name - l - 2);
- strcat (val, " ");
- l = strlen (val);
+ for(i = 2; i < argc; i++){
+ strncpy(val+l, Cmd_Argv(i), sizeof(name) - l - 2);
+ val[sizeof(val)-2] = 0;
+ strcat(val, " ");
+ l = strlen(val);
}
- putenv (name, val);
+ putenv(name, val);
+ }else if(argc == 2){
+ env = getenv(Cmd_Argv(1));
+ if(env){
+ Com_Printf("%s=%s\n", Cmd_Argv(1), env);
+ free(env);
+ }else
+ Com_Printf("%s undefined\n", Cmd_Argv(1), env);
}
- else if (argc == 2)
- {
- env = getenv (Cmd_Argv(1));
- if (env)
- {
- Com_Printf ("%s=%s\n", Cmd_Argv(1), env);
- free (env);
- }
- else
- {
- Com_Printf ("%s undefined\n", Cmd_Argv(1), env);
- }
- }
}
@@ -1064,9 +1047,9 @@
strncpy(sk, skin->string, sizeof(sk) - 1);
if ((p = strchr(sk, '/')) != NULL)
*p = 0;
- if (Q_strcasecmp(sk, "male") == 0 || Q_strcasecmp(sk, "cyborg") == 0)
+ if (cistrcmp(sk, "male") == 0 || cistrcmp(sk, "cyborg") == 0)
Cvar_Set ("gender", "male");
- else if (Q_strcasecmp(sk, "female") == 0 || Q_strcasecmp(sk, "crackhor") == 0)
+ else if (cistrcmp(sk, "female") == 0 || cistrcmp(sk, "crackhor") == 0)
Cvar_Set ("gender", "female");
else
Cvar_Set ("gender", "none");
@@ -1443,16 +1426,7 @@
cl_anglespeedkey = Cvar_Get ("cl_anglespeedkey", "1.5", 0);
cl_run = Cvar_Get ("cl_run", "0", CVAR_ARCHIVE);
- freelook = Cvar_Get( "freelook", "0", CVAR_ARCHIVE );
- lookspring = Cvar_Get ("lookspring", "0", CVAR_ARCHIVE);
- lookstrafe = Cvar_Get ("lookstrafe", "0", CVAR_ARCHIVE);
- sensitivity = Cvar_Get ("sensitivity", "3", CVAR_ARCHIVE);
- m_pitch = Cvar_Get ("m_pitch", "0.022", CVAR_ARCHIVE);
- m_yaw = Cvar_Get ("m_yaw", "0.022", 0);
- m_forward = Cvar_Get ("m_forward", "1", 0);
- m_side = Cvar_Get ("m_side", "1", 0);
-
cl_shownet = Cvar_Get ("cl_shownet", "0", 0);
cl_showmiss = Cvar_Get ("cl_showmiss", "0", 0);
cl_showclamp = Cvar_Get ("showclamp", "0", 0);
@@ -1775,7 +1749,9 @@
*/
void CL_Init (void)
{
- if (dedicated->value)
+ IN_Init();
+
+ if(dedicated->value)
return; // nothing running on the client
// all archived variables will now be loaded
@@ -1796,12 +1772,10 @@
CDAudio_Init ();
CL_InitLocal ();
- IN_Init ();
// Cbuf_AddText ("exec autoexec.cfg\n");
FS_ExecAutoexec ();
Cbuf_Execute ();
-
}
--- a/client/cl_newfx.c
+++ b/client/cl_newfx.c
@@ -27,7 +27,6 @@
extern cparticle_t *active_particles, *free_particles;
extern cparticle_t particles[MAX_PARTICLES];
extern int cl_numparticles;
-extern cvar_t *vid_ref;
extern void MakeNormalVectors (vec3_t forward, vec3_t right, vec3_t up);
--- a/client/cl_parse.c
+++ b/client/cl_parse.c
@@ -192,7 +192,8 @@
S_EndRegistration ();
}
-void rename (char *old, char *new) /* FIXME: unsafe impl. */
+static void
+rename(char *old, char *new)
{
char *p;
Dir d;
@@ -456,7 +457,7 @@
// if we don't have the skin and the model wasn't male,
// see if the male has it (this is for CTF's skins)
- if (!ci->skin && Q_strcasecmp(model_name, "male"))
+ if (!ci->skin && cistrcmp(model_name, "male"))
{
// change model to male
strcpy(model_name, "male");
--- a/client/client.h
+++ b/client/client.h
@@ -21,8 +21,6 @@
//#define PARANOID // speed sapping error checking
-#pragma pack off
-
//=============================================================================
typedef struct
{
@@ -257,17 +255,6 @@
extern cvar_t *cl_showmiss;
extern cvar_t *cl_showclamp;
-extern cvar_t *lookspring;
-extern cvar_t *lookstrafe;
-extern cvar_t *sensitivity;
-
-extern cvar_t *m_pitch;
-extern cvar_t *m_yaw;
-extern cvar_t *m_forward;
-extern cvar_t *m_side;
-
-extern cvar_t *freelook;
-
extern cvar_t *cl_lightlevel; // FIXME HACK
extern cvar_t *cl_paused;
@@ -566,5 +553,3 @@
void x86_TimerInit( unsigned long smallest, unsigned longest );
unsigned long *x86_TimerGetHistogram( void );
#endif
-
-#pragma pack on
--- a/client/input.h
+++ b/client/input.h
@@ -19,6 +19,13 @@
*/
// input.h -- external (non-keyboard) input devices
+extern cvar_t *in_joystick;
+extern cvar_t *lookspring;
+extern cvar_t *lookstrafe;
+extern cvar_t *sensitivity;
+extern cvar_t *freelook;
+extern cvar_t *m_pitch;
+
void IN_Init (void);
void IN_Shutdown (void);
--- a/client/keys.c
+++ b/client/keys.c
@@ -462,7 +462,7 @@
for (kn=keynames ; kn->name ; kn++)
{
- if (!Q_strcasecmp(str,kn->name))
+ if (!cistrcmp(str,kn->name))
return kn->keynum;
}
return -1;
--- a/client/menu.c
+++ b/client/menu.c
@@ -1014,7 +1014,6 @@
=======================================================================
*/
static cvar_t *win_noalttab;
-extern cvar_t *in_joystick;
static menuframework_s s_options_menu;
static menuaction_s s_options_defaults_action;
@@ -2255,7 +2254,7 @@
index = ( menuaction_s * ) self - s_joinserver_server_actions;
- if ( Q_strcasecmp( local_server_names[index], NO_SERVER_STRING ) == 0 )
+ if ( cistrcmp( local_server_names[index], NO_SERVER_STRING ) == 0 )
return;
if (index >= m_num_servers)
@@ -2473,21 +2472,21 @@
spot = NULL;
if (s_rules_box.curvalue == 1) // PGM
{
- if(Q_strcasecmp(startmap, "bunk1") == 0)
+ if(cistrcmp(startmap, "bunk1") == 0)
spot = "start";
- else if(Q_strcasecmp(startmap, "mintro") == 0)
+ else if(cistrcmp(startmap, "mintro") == 0)
spot = "start";
- else if(Q_strcasecmp(startmap, "fact1") == 0)
+ else if(cistrcmp(startmap, "fact1") == 0)
spot = "start";
- else if(Q_strcasecmp(startmap, "power1") == 0)
+ else if(cistrcmp(startmap, "power1") == 0)
spot = "pstart";
- else if(Q_strcasecmp(startmap, "biggun") == 0)
+ else if(cistrcmp(startmap, "biggun") == 0)
spot = "bstart";
- else if(Q_strcasecmp(startmap, "hangar1") == 0)
+ else if(cistrcmp(startmap, "hangar1") == 0)
spot = "unitstart";
- else if(Q_strcasecmp(startmap, "city1") == 0)
+ else if(cistrcmp(startmap, "city1") == 0)
spot = "unitstart";
- else if(Q_strcasecmp(startmap, "boss1") == 0)
+ else if(cistrcmp(startmap, "boss1") == 0)
spot = "bosstart";
}
@@ -3651,7 +3650,7 @@
for ( i = 0; i < s_numplayermodels; i++ )
{
s_pmnames[i] = s_pmi[i].displayname;
- if ( Q_strcasecmp( s_pmi[i].directory, currentdirectory ) == 0 )
+ if ( cistrcmp( s_pmi[i].directory, currentdirectory ) == 0 )
{
int j;
@@ -3659,7 +3658,7 @@
for ( j = 0; j < s_pmi[i].nskins; j++ )
{
- if ( Q_strcasecmp( s_pmi[i].skindisplaynames[j], currentskin ) == 0 )
+ if ( cistrcmp( s_pmi[i].skindisplaynames[j], currentskin ) == 0 )
{
currentskinindex = j;
break;
--- a/client/ref.h
+++ b/client/ref.h
@@ -220,3 +220,6 @@
// this is the only function actually exported at the linker level
typedef refexport_t (*GetRefAPI_t) (refimport_t);
+
+extern cvar_t *vid_fullscreen;
+extern cvar_t *vid_gamma;
--- a/ctf/g_cmds.c
+++ b/ctf/g_cmds.c
@@ -178,12 +178,12 @@
name = gi.args();
- if (Q_strcasecmp(name, "all") == 0)
+ if (cistrcmp(name, "all") == 0)
give_all = true;
else
give_all = false;
- if (give_all || Q_strcasecmp(gi.argv(1), "health") == 0)
+ if (give_all || cistrcmp(gi.argv(1), "health") == 0)
{
if (gi.argc() == 3)
ent->health = atoi(gi.argv(2));
@@ -193,7 +193,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "weapons") == 0)
+ if (give_all || cistrcmp(name, "weapons") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
@@ -208,7 +208,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "ammo") == 0)
+ if (give_all || cistrcmp(name, "ammo") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
@@ -223,7 +223,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "armor") == 0)
+ if (give_all || cistrcmp(name, "armor") == 0)
{
gitem_armor_t *info;
@@ -241,7 +241,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "Power Shield") == 0)
+ if (give_all || cistrcmp(name, "Power Shield") == 0)
{
it = FindItem("Power Shield");
it_ent = G_Spawn();
@@ -448,7 +448,7 @@
char *s;
//ZOID--special case for tech powerups
- if (Q_strcasecmp(gi.args(), "tech") == 0 && (it = CTFWhat_Tech(ent)) != NULL) {
+ if (cistrcmp(gi.args(), "tech") == 0 && (it = CTFWhat_Tech(ent)) != NULL) {
it->drop (ent, it);
return;
}
@@ -962,27 +962,27 @@
cmd = gi.argv(0);
- if (Q_strcasecmp (cmd, "players") == 0)
+ if (cistrcmp (cmd, "players") == 0)
{
Cmd_Players_f (ent);
return;
}
- if (Q_strcasecmp (cmd, "say") == 0)
+ if (cistrcmp (cmd, "say") == 0)
{
Cmd_Say_f (ent, false, false);
return;
}
- if (Q_strcasecmp (cmd, "say_team") == 0 || Q_strcasecmp (cmd, "steam") == 0)
+ if (cistrcmp (cmd, "say_team") == 0 || cistrcmp (cmd, "steam") == 0)
{
CTFSay_Team(ent, gi.args());
return;
}
- if (Q_strcasecmp (cmd, "score") == 0)
+ if (cistrcmp (cmd, "score") == 0)
{
Cmd_Score_f (ent);
return;
}
- if (Q_strcasecmp (cmd, "help") == 0)
+ if (cistrcmp (cmd, "help") == 0)
{
Cmd_Help_f (ent);
return;
@@ -991,75 +991,75 @@
if (level.intermissiontime)
return;
- if (Q_strcasecmp (cmd, "use") == 0)
+ if (cistrcmp (cmd, "use") == 0)
Cmd_Use_f (ent);
- else if (Q_strcasecmp (cmd, "drop") == 0)
+ else if (cistrcmp (cmd, "drop") == 0)
Cmd_Drop_f (ent);
- else if (Q_strcasecmp (cmd, "give") == 0)
+ else if (cistrcmp (cmd, "give") == 0)
Cmd_Give_f (ent);
- else if (Q_strcasecmp (cmd, "god") == 0)
+ else if (cistrcmp (cmd, "god") == 0)
Cmd_God_f (ent);
- else if (Q_strcasecmp (cmd, "notarget") == 0)
+ else if (cistrcmp (cmd, "notarget") == 0)
Cmd_Notarget_f (ent);
- else if (Q_strcasecmp (cmd, "noclip") == 0)
+ else if (cistrcmp (cmd, "noclip") == 0)
Cmd_Noclip_f (ent);
- else if (Q_strcasecmp (cmd, "inven") == 0)
+ else if (cistrcmp (cmd, "inven") == 0)
Cmd_Inven_f (ent);
- else if (Q_strcasecmp (cmd, "invnext") == 0)
+ else if (cistrcmp (cmd, "invnext") == 0)
SelectNextItem (ent, -1);
- else if (Q_strcasecmp (cmd, "invprev") == 0)
+ else if (cistrcmp (cmd, "invprev") == 0)
SelectPrevItem (ent, -1);
- else if (Q_strcasecmp (cmd, "invnextw") == 0)
+ else if (cistrcmp (cmd, "invnextw") == 0)
SelectNextItem (ent, IT_WEAPON);
- else if (Q_strcasecmp (cmd, "invprevw") == 0)
+ else if (cistrcmp (cmd, "invprevw") == 0)
SelectPrevItem (ent, IT_WEAPON);
- else if (Q_strcasecmp (cmd, "invnextp") == 0)
+ else if (cistrcmp (cmd, "invnextp") == 0)
SelectNextItem (ent, IT_POWERUP);
- else if (Q_strcasecmp (cmd, "invprevp") == 0)
+ else if (cistrcmp (cmd, "invprevp") == 0)
SelectPrevItem (ent, IT_POWERUP);
- else if (Q_strcasecmp (cmd, "invuse") == 0)
+ else if (cistrcmp (cmd, "invuse") == 0)
Cmd_InvUse_f (ent);
- else if (Q_strcasecmp (cmd, "invdrop") == 0)
+ else if (cistrcmp (cmd, "invdrop") == 0)
Cmd_InvDrop_f (ent);
- else if (Q_strcasecmp (cmd, "weapprev") == 0)
+ else if (cistrcmp (cmd, "weapprev") == 0)
Cmd_WeapPrev_f (ent);
- else if (Q_strcasecmp (cmd, "weapnext") == 0)
+ else if (cistrcmp (cmd, "weapnext") == 0)
Cmd_WeapNext_f (ent);
- else if (Q_strcasecmp (cmd, "weaplast") == 0)
+ else if (cistrcmp (cmd, "weaplast") == 0)
Cmd_WeapLast_f (ent);
- else if (Q_strcasecmp (cmd, "kill") == 0)
+ else if (cistrcmp (cmd, "kill") == 0)
Cmd_Kill_f (ent);
- else if (Q_strcasecmp (cmd, "putaway") == 0)
+ else if (cistrcmp (cmd, "putaway") == 0)
Cmd_PutAway_f (ent);
- else if (Q_strcasecmp (cmd, "wave") == 0)
+ else if (cistrcmp (cmd, "wave") == 0)
Cmd_Wave_f (ent);
//ZOID
- else if (Q_strcasecmp (cmd, "team") == 0)
+ else if (cistrcmp (cmd, "team") == 0)
{
CTFTeam_f (ent);
- } else if (Q_strcasecmp(cmd, "id") == 0) {
+ } else if (cistrcmp(cmd, "id") == 0) {
CTFID_f (ent);
- } else if (Q_strcasecmp(cmd, "yes") == 0) {
+ } else if (cistrcmp(cmd, "yes") == 0) {
CTFVoteYes(ent);
- } else if (Q_strcasecmp(cmd, "no") == 0) {
+ } else if (cistrcmp(cmd, "no") == 0) {
CTFVoteNo(ent);
- } else if (Q_strcasecmp(cmd, "ready") == 0) {
+ } else if (cistrcmp(cmd, "ready") == 0) {
CTFReady(ent);
- } else if (Q_strcasecmp(cmd, "notready") == 0) {
+ } else if (cistrcmp(cmd, "notready") == 0) {
CTFNotReady(ent);
- } else if (Q_strcasecmp(cmd, "ghost") == 0) {
+ } else if (cistrcmp(cmd, "ghost") == 0) {
CTFGhost(ent);
- } else if (Q_strcasecmp(cmd, "admin") == 0) {
+ } else if (cistrcmp(cmd, "admin") == 0) {
CTFAdmin(ent);
- } else if (Q_strcasecmp(cmd, "stats") == 0) {
+ } else if (cistrcmp(cmd, "stats") == 0) {
CTFStats(ent);
- } else if (Q_strcasecmp(cmd, "warp") == 0) {
+ } else if (cistrcmp(cmd, "warp") == 0) {
CTFWarp(ent);
- } else if (Q_strcasecmp(cmd, "boot") == 0) {
+ } else if (cistrcmp(cmd, "boot") == 0) {
CTFBoot(ent);
- } else if (Q_strcasecmp(cmd, "playerlist") == 0) {
+ } else if (cistrcmp(cmd, "playerlist") == 0) {
CTFPlayerList(ent);
- } else if (Q_strcasecmp(cmd, "observer") == 0) {
+ } else if (cistrcmp(cmd, "observer") == 0) {
CTFObserver(ent);
}
//ZOID
--- a/ctf/g_ctf.c
+++ b/ctf/g_ctf.c
@@ -1535,9 +1535,9 @@
return;
}
- if (Q_strcasecmp(t, "red") == 0)
+ if (cistrcmp(t, "red") == 0)
desired_team = CTF_TEAM1;
- else if (Q_strcasecmp(t, "blue") == 0)
+ else if (cistrcmp(t, "blue") == 0)
desired_team = CTF_TEAM2;
else {
gi.cprintf(ent, PRINT_HIGH, "Unknown team %s.\n", t);
@@ -3128,10 +3128,10 @@
}
if (ctf_forcejoin->string && *ctf_forcejoin->string) {
- if (stricmp(ctf_forcejoin->string, "red") == 0) {
+ if(!cistrcmp(ctf_forcejoin->string, "red")){
joinmenu[jmenu_blue].text = NULL;
joinmenu[jmenu_blue].SelectFunc = NULL;
- } else if (stricmp(ctf_forcejoin->string, "blue") == 0) {
+ }else if(!cistrcmp(ctf_forcejoin->string, "blue")){
joinmenu[jmenu_red].text = NULL;
joinmenu[jmenu_red].SelectFunc = NULL;
}
@@ -3948,7 +3948,7 @@
token = strtok(mlist, seps);
while (token != NULL) {
- if (Q_strcasecmp(token, gi.argv(1)) == 0)
+ if (cistrcmp(token, gi.argv(1)) == 0)
break;
token = strtok(NULL, seps);
}
--- a/ctf/g_func.c
+++ b/ctf/g_func.c
@@ -860,7 +860,7 @@
while ((t = G_Find (t, FOFS(targetname), self->target)))
{
- if (Q_strcasecmp(t->classname, "func_areaportal") == 0)
+ if (cistrcmp(t->classname, "func_areaportal") == 0)
{
gi.SetAreaPortalState (t->style, open);
}
--- a/ctf/g_items.c
+++ b/ctf/g_items.c
@@ -86,7 +86,7 @@
{
if (!it->classname)
continue;
- if (!Q_strcasecmp(it->classname, classname))
+ if (!cistrcmp(it->classname, classname))
return it;
}
@@ -109,7 +109,7 @@
{
if (!it->pickup_name)
continue;
- if (!Q_strcasecmp(it->pickup_name, pickup_name))
+ if (!cistrcmp(it->pickup_name, pickup_name))
return it;
}
--- a/ctf/g_main.c
+++ b/ctf/g_main.c
@@ -213,7 +213,7 @@
f = NULL;
t = strtok(s, seps);
while (t != NULL) {
- if (Q_strcasecmp(t, level.mapname) == 0) {
+ if (cistrcmp(t, level.mapname) == 0) {
// it's in the list, go to the next one
t = strtok(NULL, seps);
if (t == NULL) { // end of list, go to first one
--- a/ctf/g_spawn.c
+++ b/ctf/g_spawn.c
@@ -385,7 +385,7 @@
for (f=fields ; f->name ; f++)
{
- if (!Q_strcasecmp(f->name, key))
+ if (!cistrcmp(f->name, key))
{ // found it
if (f->flags & FFL_SPAWNTEMP)
b = (byte *)&st;
@@ -588,7 +588,7 @@
entities = ED_ParseEdict (entities, ent);
// yet another map hack
- if (!stricmp(level.mapname, "command") && !stricmp(ent->classname, "trigger_once") && !stricmp(ent->model, "*27"))
+ if(!cistrcmp(level.mapname, "command") && !cistrcmp(ent->classname, "trigger_once") && !cistrcmp(ent->model, "*27"))
ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
// remove things (except the world) from different skill levels or deathmatch
--- a/ctf/g_svcmds.c
+++ b/ctf/g_svcmds.c
@@ -41,7 +41,7 @@
char *cmd;
cmd = gi.argv(1);
- if (Q_strcasecmp (cmd, "test") == 0)
+ if (cistrcmp (cmd, "test") == 0)
Svcmd_Test_f ();
else
gi.cprintf (NULL, PRINT_HIGH, "Unknown server command \"%s\"\n", cmd);
--- a/ctf/g_target.c
+++ b/ctf/g_target.c
@@ -178,7 +178,7 @@
ent->svflags = SVF_NOCLIENT;
level.total_secrets++;
// map bug hack
- if (!stricmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624)
+ if (!cistrcmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624)
ent->message = "You have found a secret area.";
}
@@ -311,7 +311,7 @@
}
// ugly hack because *SOMEBODY* screwed up their map
- if((stricmp(level.mapname, "fact1") == 0) && (stricmp(ent->map, "fact3") == 0))
+ if((cistrcmp(level.mapname, "fact1") == 0) && (cistrcmp(ent->map, "fact3") == 0))
ent->map = "fact3$secret1";
ent->use = use_target_changelevel;
--- a/ctf/g_utils.c
+++ b/ctf/g_utils.c
@@ -59,7 +59,7 @@
s = *(char **) ((byte *)from + fieldofs);
if (!s)
continue;
- if (!Q_strcasecmp (s, match))
+ if (!cistrcmp (s, match))
return from;
}
@@ -235,8 +235,8 @@
while ((t = G_Find (t, FOFS(targetname), ent->target)))
{
// doors fire area portals in a specific way
- if (!Q_strcasecmp(t->classname, "func_areaportal") &&
- (!Q_strcasecmp(ent->classname, "func_door") || !Q_strcasecmp(ent->classname, "func_door_rotating")))
+ if (!cistrcmp(t->classname, "func_areaportal") &&
+ (!cistrcmp(ent->classname, "func_door") || !cistrcmp(ent->classname, "func_door_rotating")))
continue;
if (t == ent)
--- a/ctf/p_client.c
+++ b/ctf/p_client.c
@@ -55,7 +55,7 @@
VectorSubtract(self->s.origin, spot->s.origin, d);
if (VectorLength(d) < 384)
{
- if ((!self->targetname) || stricmp(self->targetname, spot->targetname) != 0)
+ if ((!self->targetname) || cistrcmp(self->targetname, spot->targetname) != 0)
{
// gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname);
self->targetname = spot->targetname;
@@ -73,7 +73,7 @@
{
edict_t *spot;
- if(stricmp(level.mapname, "security") == 0)
+ if(cistrcmp(level.mapname, "security") == 0)
{
spot = G_Spawn();
spot->classname = "info_player_coop";
@@ -111,7 +111,7 @@
{
if (!coop->value)
return;
- if(stricmp(level.mapname, "security") == 0)
+ if(cistrcmp(level.mapname, "security") == 0)
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_CreateCoopSpots;
@@ -144,20 +144,20 @@
return;
}
- if((stricmp(level.mapname, "jail2") == 0) ||
- (stricmp(level.mapname, "jail4") == 0) ||
- (stricmp(level.mapname, "mine1") == 0) ||
- (stricmp(level.mapname, "mine2") == 0) ||
- (stricmp(level.mapname, "mine3") == 0) ||
- (stricmp(level.mapname, "mine4") == 0) ||
- (stricmp(level.mapname, "lab") == 0) ||
- (stricmp(level.mapname, "boss1") == 0) ||
- (stricmp(level.mapname, "fact3") == 0) ||
- (stricmp(level.mapname, "biggun") == 0) ||
- (stricmp(level.mapname, "space") == 0) ||
- (stricmp(level.mapname, "command") == 0) ||
- (stricmp(level.mapname, "power2") == 0) ||
- (stricmp(level.mapname, "strike") == 0))
+ if((cistrcmp(level.mapname, "jail2") == 0) ||
+ (cistrcmp(level.mapname, "jail4") == 0) ||
+ (cistrcmp(level.mapname, "mine1") == 0) ||
+ (cistrcmp(level.mapname, "mine2") == 0) ||
+ (cistrcmp(level.mapname, "mine3") == 0) ||
+ (cistrcmp(level.mapname, "mine4") == 0) ||
+ (cistrcmp(level.mapname, "lab") == 0) ||
+ (cistrcmp(level.mapname, "boss1") == 0) ||
+ (cistrcmp(level.mapname, "fact3") == 0) ||
+ (cistrcmp(level.mapname, "biggun") == 0) ||
+ (cistrcmp(level.mapname, "space") == 0) ||
+ (cistrcmp(level.mapname, "command") == 0) ||
+ (cistrcmp(level.mapname, "power2") == 0) ||
+ (cistrcmp(level.mapname, "strike") == 0))
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_FixCoopSpots;
@@ -882,7 +882,7 @@
target = spot->targetname;
if (!target)
target = "";
- if ( Q_strcasecmp(game.spawnpoint, target) == 0 )
+ if ( cistrcmp(game.spawnpoint, target) == 0 )
{ // this is a coop spawn point for one of the clients here
index--;
if (!index)
@@ -927,7 +927,7 @@
if (!game.spawnpoint[0] || !spot->targetname)
continue;
- if (Q_strcasecmp(game.spawnpoint, spot->targetname) == 0)
+ if (cistrcmp(game.spawnpoint, spot->targetname) == 0)
break;
}
--- a/ctf/p_weapon.c
+++ b/ctf/p_weapon.c
@@ -554,12 +554,12 @@
fire_frames, fire);
// run the weapon frame again if hasted
- if (stricmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
+ if (cistrcmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
ent->client->weaponstate == WEAPON_FIRING)
return;
if ((CTFApplyHaste(ent) ||
- (Q_strcasecmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
+ (cistrcmp(ent->client->pers.weapon->pickup_name, "Grapple") == 0 &&
ent->client->weaponstate != WEAPON_FIRING))
&& oldstate == ent->client->weaponstate) {
Weapon_Generic2 (ent, FRAME_ACTIVATE_LAST, FRAME_FIRE_LAST,
--- a/ctf/q_shared.c
+++ b/ctf/q_shared.c
@@ -26,10 +26,6 @@
//============================================================================
-#ifdef _WIN32
-#pragma optimize( "", off )
-#endif
-
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees )
{
float m[3][3];
@@ -85,12 +81,6 @@
}
}
-#ifdef _WIN32
-#pragma optimize( "", on )
-#endif
-
-
-
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{
float angle;
@@ -251,31 +241,16 @@
float Q_fabs (float f)
{
-#if 0
+ /*
if (f >= 0)
return f;
return -f;
-#else
+ */
int tmp = * ( int * ) &f;
tmp &= 0x7FFFFFFF;
return * ( float * ) &tmp;
-#endif
}
-#if defined _M_IX86 && !defined C_ONLY
-#pragma warning (disable:4035)
-//__declspec( naked ) long Q_ftol( float f )
-long Q_ftol( float f )
-{
- static int tmp;
- __asm fld dword ptr [esp+4]
- __asm fistp tmp
- __asm mov eax, tmp
- __asm ret
-}
-#pragma warning (default:4035)
-#endif
-
/*
===============
LerpAngle
@@ -347,7 +322,6 @@
Returns 1, 2, or 1 + 2
==================
*/
-//#if !id386
int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
{
float dist1, dist2;
@@ -414,244 +388,7 @@
return sides;
}
-//#else
-#pragma warning( disable: 4035 )
-/*
-//__declspec( naked ) int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
-int BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct cplane_s *p)
-{
- static int bops_initialized;
- static int Ljmptab[8];
-
- __asm {
-
- push ebx
-
- cmp bops_initialized, 1
- je initialized
- mov bops_initialized, 1
-
- mov Ljmptab[0*4], offset Lcase0
- mov Ljmptab[1*4], offset Lcase1
- mov Ljmptab[2*4], offset Lcase2
- mov Ljmptab[3*4], offset Lcase3
- mov Ljmptab[4*4], offset Lcase4
- mov Ljmptab[5*4], offset Lcase5
- mov Ljmptab[6*4], offset Lcase6
- mov Ljmptab[7*4], offset Lcase7
-
-initialized:
-
- mov edx,ds:dword ptr[4+12+esp]
- mov ecx,ds:dword ptr[4+4+esp]
- xor eax,eax
- mov ebx,ds:dword ptr[4+8+esp]
- mov al,ds:byte ptr[17+edx]
- cmp al,8
- jge Lerror
- fld ds:dword ptr[0+edx]
- fld st(0)
- jmp dword ptr[Ljmptab+eax*4]
-Lcase0:
- fmul ds:dword ptr[ebx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ebx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase1:
- fmul ds:dword ptr[ecx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ebx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase2:
- fmul ds:dword ptr[ebx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ecx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase3:
- fmul ds:dword ptr[ecx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ecx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase4:
- fmul ds:dword ptr[ebx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ebx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase5:
- fmul ds:dword ptr[ecx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ebx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase6:
- fmul ds:dword ptr[ebx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ecx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ecx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
- jmp LSetSides
-Lcase7:
- fmul ds:dword ptr[ecx]
- fld ds:dword ptr[0+4+edx]
- fxch st(2)
- fmul ds:dword ptr[ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[4+ecx]
- fld ds:dword ptr[0+8+edx]
- fxch st(2)
- fmul ds:dword ptr[4+ebx]
- fxch st(2)
- fld st(0)
- fmul ds:dword ptr[8+ecx]
- fxch st(5)
- faddp st(3),st(0)
- fmul ds:dword ptr[8+ebx]
- fxch st(1)
- faddp st(3),st(0)
- fxch st(3)
- faddp st(2),st(0)
-LSetSides:
- faddp st(2),st(0)
- fcomp ds:dword ptr[12+edx]
- xor ecx,ecx
- fnstsw ax
- fcomp ds:dword ptr[12+edx]
- and ah,1
- xor ah,1
- add cl,ah
- fnstsw ax
- and ah,1
- add ah,ah
- add cl,ah
- pop ebx
- mov eax,ecx
- ret
-Lerror:
- int 3
- }
-}
-#pragma warning( default: 4035 )
-//#endif
-*/
-
void ClearBounds (vec3_t mins, vec3_t maxs)
{
mins[0] = mins[1] = mins[2] = 99999;
@@ -1171,49 +908,6 @@
for (i=size-1 ; i>0 ; i-=4096)
paged_total += buffer[i];
}
-
-
-
-/*
-============================================================================
-
- LIBRARY REPLACEMENT FUNCTIONS
-
-============================================================================
-*/
-
-int Q_strncasecmp (char *s1, char *s2, int n)
-{
- int c1, c2;
-
- do
- {
- c1 = *s1++;
- c2 = *s2++;
-
- if (!n--)
- return 0; // strings are equal until end point
-
- if (c1 != c2)
- {
- if (c1 >= 'a' && c1 <= 'z')
- c1 -= ('a' - 'A');
- if (c2 >= 'a' && c2 <= 'z')
- c2 -= ('a' - 'A');
- if (c1 != c2)
- return -1; // strings not equal
- }
- } while (c1);
-
- return 0; // strings are equal
-}
-
-int Q_strcasecmp (char *s1, char *s2)
-{
- return Q_strncasecmp (s1, s2, 99999);
-}
-
-
void Com_sprintf (char *dest, int size, char *fmt, ...)
{
--- a/game/g_cmds.c
+++ b/game/g_cmds.c
@@ -169,12 +169,12 @@
name = gi.args();
- if (Q_strcasecmp(name, "all") == 0)
+ if (cistrcmp(name, "all") == 0)
give_all = true;
else
give_all = false;
- if (give_all || Q_strcasecmp(gi.argv(1), "health") == 0)
+ if (give_all || cistrcmp(gi.argv(1), "health") == 0)
{
if (gi.argc() == 3)
ent->health = atoi(gi.argv(2));
@@ -184,7 +184,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "weapons") == 0)
+ if (give_all || cistrcmp(name, "weapons") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
@@ -199,7 +199,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "ammo") == 0)
+ if (give_all || cistrcmp(name, "ammo") == 0)
{
for (i=0 ; i<game.num_items ; i++)
{
@@ -214,7 +214,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "armor") == 0)
+ if (give_all || cistrcmp(name, "armor") == 0)
{
gitem_armor_t *info;
@@ -232,7 +232,7 @@
return;
}
- if (give_all || Q_strcasecmp(name, "Power Shield") == 0)
+ if (give_all || cistrcmp(name, "Power Shield") == 0)
{
it = FindItem("Power Shield");
it_ent = G_Spawn();
@@ -917,27 +917,27 @@
cmd = gi.argv(0);
- if (Q_strcasecmp (cmd, "players") == 0)
+ if (cistrcmp (cmd, "players") == 0)
{
Cmd_Players_f (ent);
return;
}
- if (Q_strcasecmp (cmd, "say") == 0)
+ if (cistrcmp (cmd, "say") == 0)
{
Cmd_Say_f (ent, false, false);
return;
}
- if (Q_strcasecmp (cmd, "say_team") == 0)
+ if (cistrcmp (cmd, "say_team") == 0)
{
Cmd_Say_f (ent, true, false);
return;
}
- if (Q_strcasecmp (cmd, "score") == 0)
+ if (cistrcmp (cmd, "score") == 0)
{
Cmd_Score_f (ent);
return;
}
- if (Q_strcasecmp (cmd, "help") == 0)
+ if (cistrcmp (cmd, "help") == 0)
{
Cmd_Help_f (ent);
return;
@@ -946,49 +946,49 @@
if (level.intermissiontime)
return;
- if (Q_strcasecmp (cmd, "use") == 0)
+ if (cistrcmp (cmd, "use") == 0)
Cmd_Use_f (ent);
- else if (Q_strcasecmp (cmd, "drop") == 0)
+ else if (cistrcmp (cmd, "drop") == 0)
Cmd_Drop_f (ent);
- else if (Q_strcasecmp (cmd, "give") == 0)
+ else if (cistrcmp (cmd, "give") == 0)
Cmd_Give_f (ent);
- else if (Q_strcasecmp (cmd, "god") == 0)
+ else if (cistrcmp (cmd, "god") == 0)
Cmd_God_f (ent);
- else if (Q_strcasecmp (cmd, "notarget") == 0)
+ else if (cistrcmp (cmd, "notarget") == 0)
Cmd_Notarget_f (ent);
- else if (Q_strcasecmp (cmd, "noclip") == 0)
+ else if (cistrcmp (cmd, "noclip") == 0)
Cmd_Noclip_f (ent);
- else if (Q_strcasecmp (cmd, "inven") == 0)
+ else if (cistrcmp (cmd, "inven") == 0)
Cmd_Inven_f (ent);
- else if (Q_strcasecmp (cmd, "invnext") == 0)
+ else if (cistrcmp (cmd, "invnext") == 0)
SelectNextItem (ent, -1);
- else if (Q_strcasecmp (cmd, "invprev") == 0)
+ else if (cistrcmp (cmd, "invprev") == 0)
SelectPrevItem (ent, -1);
- else if (Q_strcasecmp (cmd, "invnextw") == 0)
+ else if (cistrcmp (cmd, "invnextw") == 0)
SelectNextItem (ent, IT_WEAPON);
- else if (Q_strcasecmp (cmd, "invprevw") == 0)
+ else if (cistrcmp (cmd, "invprevw") == 0)
SelectPrevItem (ent, IT_WEAPON);
- else if (Q_strcasecmp (cmd, "invnextp") == 0)
+ else if (cistrcmp (cmd, "invnextp") == 0)
SelectNextItem (ent, IT_POWERUP);
- else if (Q_strcasecmp (cmd, "invprevp") == 0)
+ else if (cistrcmp (cmd, "invprevp") == 0)
SelectPrevItem (ent, IT_POWERUP);
- else if (Q_strcasecmp (cmd, "invuse") == 0)
+ else if (cistrcmp (cmd, "invuse") == 0)
Cmd_InvUse_f (ent);
- else if (Q_strcasecmp (cmd, "invdrop") == 0)
+ else if (cistrcmp (cmd, "invdrop") == 0)
Cmd_InvDrop_f (ent);
- else if (Q_strcasecmp (cmd, "weapprev") == 0)
+ else if (cistrcmp (cmd, "weapprev") == 0)
Cmd_WeapPrev_f (ent);
- else if (Q_strcasecmp (cmd, "weapnext") == 0)
+ else if (cistrcmp (cmd, "weapnext") == 0)
Cmd_WeapNext_f (ent);
- else if (Q_strcasecmp (cmd, "weaplast") == 0)
+ else if (cistrcmp (cmd, "weaplast") == 0)
Cmd_WeapLast_f (ent);
- else if (Q_strcasecmp (cmd, "kill") == 0)
+ else if (cistrcmp (cmd, "kill") == 0)
Cmd_Kill_f (ent);
- else if (Q_strcasecmp (cmd, "putaway") == 0)
+ else if (cistrcmp (cmd, "putaway") == 0)
Cmd_PutAway_f (ent);
- else if (Q_strcasecmp (cmd, "wave") == 0)
+ else if (cistrcmp (cmd, "wave") == 0)
Cmd_Wave_f (ent);
- else if (Q_strcasecmp(cmd, "playerlist") == 0)
+ else if (cistrcmp(cmd, "playerlist") == 0)
Cmd_PlayerList_f(ent);
else // anything that doesn't match a command will be a chat
Cmd_Say_f (ent, false, true);
--- a/game/g_func.c
+++ b/game/g_func.c
@@ -861,7 +861,7 @@
while ((t = G_Find (t, FOFS(targetname), self->target)))
{
- if (Q_strcasecmp(t->classname, "func_areaportal") == 0)
+ if (cistrcmp(t->classname, "func_areaportal") == 0)
{
gi.SetAreaPortalState (t->style, open);
}
--- a/game/g_items.c
+++ b/game/g_items.c
@@ -87,7 +87,7 @@
{
if (!it->classname)
continue;
- if (!Q_strcasecmp(it->classname, classname))
+ if (!cistrcmp(it->classname, classname))
return it;
}
@@ -110,7 +110,7 @@
{
if (!it->pickup_name)
continue;
- if (!Q_strcasecmp(it->pickup_name, pickup_name))
+ if (!cistrcmp(it->pickup_name, pickup_name))
return it;
}
--- a/game/g_main.c
+++ b/game/g_main.c
@@ -209,7 +209,7 @@
f = NULL;
t = strtok(s, seps);
while (t != NULL) {
- if (Q_strcasecmp(t, level.mapname) == 0) {
+ if (cistrcmp(t, level.mapname) == 0) {
// it's in the list, go to the next one
t = strtok(NULL, seps);
if (t == NULL) { // end of list, go to first one
--- a/game/g_spawn.c
+++ b/game/g_spawn.c
@@ -366,7 +366,7 @@
for (f=fields ; f->name ; f++)
{
- if (!(f->flags & FFL_NOSPAWN) && !Q_strcasecmp(f->name, key))
+ if (!(f->flags & FFL_NOSPAWN) && !cistrcmp(f->name, key))
{ // found it
if (f->flags & FFL_SPAWNTEMP)
b = (byte *)&st;
@@ -569,7 +569,7 @@
entities = ED_ParseEdict (entities, ent);
// yet another map hack
- if (!Q_strcasecmp(level.mapname, "command") && !Q_strcasecmp(ent->classname, "trigger_once") && !Q_strcasecmp(ent->model, "*27"))
+ if (!cistrcmp(level.mapname, "command") && !cistrcmp(ent->classname, "trigger_once") && !cistrcmp(ent->model, "*27"))
ent->spawnflags &= ~SPAWNFLAG_NOT_HARD;
// remove things (except the world) from different skill levels or deathmatch
--- a/game/g_svcmds.c
+++ b/game/g_svcmds.c
@@ -286,15 +286,15 @@
char *cmd;
cmd = gi.argv(1);
- if (Q_strcasecmp (cmd, "test") == 0)
+ if (cistrcmp (cmd, "test") == 0)
Svcmd_Test_f ();
- else if (Q_strcasecmp (cmd, "addip") == 0)
+ else if (cistrcmp (cmd, "addip") == 0)
SVCmd_AddIP_f ();
- else if (Q_strcasecmp (cmd, "removeip") == 0)
+ else if (cistrcmp (cmd, "removeip") == 0)
SVCmd_RemoveIP_f ();
- else if (Q_strcasecmp (cmd, "listip") == 0)
+ else if (cistrcmp (cmd, "listip") == 0)
SVCmd_ListIP_f ();
- else if (Q_strcasecmp (cmd, "writeip") == 0)
+ else if (cistrcmp (cmd, "writeip") == 0)
SVCmd_WriteIP_f ();
else
gi.cprintf (NULL, PRINT_HIGH, "Unknown server command \"%s\"\n", cmd);
--- a/game/g_target.c
+++ b/game/g_target.c
@@ -179,7 +179,7 @@
ent->svflags = SVF_NOCLIENT;
level.total_secrets++;
// map bug hack
- if (!Q_strcasecmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624)
+ if (!cistrcmp(level.mapname, "mine3") && ent->s.origin[0] == 280 && ent->s.origin[1] == -2048 && ent->s.origin[2] == -624)
ent->message = "You have found a secret area.";
}
@@ -312,7 +312,7 @@
}
// ugly hack because *SOMEBODY* screwed up their map
- if((Q_strcasecmp(level.mapname, "fact1") == 0) && (Q_strcasecmp(ent->map, "fact3") == 0))
+ if((cistrcmp(level.mapname, "fact1") == 0) && (cistrcmp(ent->map, "fact3") == 0))
ent->map = "fact3$secret1";
ent->use = use_target_changelevel;
--- a/game/g_utils.c
+++ b/game/g_utils.c
@@ -60,7 +60,7 @@
s = *(char **) ((byte *)from + fieldofs);
if (!s)
continue;
- if (!Q_strcasecmp (s, match))
+ if (!cistrcmp (s, match))
return from;
}
@@ -234,8 +234,8 @@
while ((t = G_Find (t, FOFS(targetname), ent->target)))
{
// doors fire area portals in a specific way
- if (!Q_strcasecmp(t->classname, "func_areaportal") &&
- (!Q_strcasecmp(ent->classname, "func_door") || !Q_strcasecmp(ent->classname, "func_door_rotating")))
+ if (!cistrcmp(t->classname, "func_areaportal") &&
+ (!cistrcmp(ent->classname, "func_door") || !cistrcmp(ent->classname, "func_door_rotating")))
continue;
if (t == ent)
--- a/game/m_flyer.c
+++ b/game/m_flyer.c
@@ -574,7 +574,7 @@
}
// fix a map bug in jail5.bsp
- if (!Q_strcasecmp(level.mapname, "jail5") && (self->s.origin[2] == -104))
+ if (!cistrcmp(level.mapname, "jail5") && (self->s.origin[2] == -104))
{
self->targetname = self->target;
self->target = NULL;
--- a/game/p_client.c
+++ b/game/p_client.c
@@ -56,7 +56,7 @@
VectorSubtract(self->s.origin, spot->s.origin, d);
if (VectorLength(d) < 384)
{
- if ((!self->targetname) || Q_strcasecmp(self->targetname, spot->targetname) != 0)
+ if ((!self->targetname) || cistrcmp(self->targetname, spot->targetname) != 0)
{
// gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname);
self->targetname = spot->targetname;
@@ -74,7 +74,7 @@
{
edict_t *spot;
- if(Q_strcasecmp(level.mapname, "security") == 0)
+ if(cistrcmp(level.mapname, "security") == 0)
{
spot = G_Spawn();
spot->classname = "info_player_coop";
@@ -112,7 +112,7 @@
{
if (!coop->value)
return;
- if(Q_strcasecmp(level.mapname, "security") == 0)
+ if(cistrcmp(level.mapname, "security") == 0)
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_CreateCoopSpots;
@@ -145,20 +145,20 @@
return;
}
- if((Q_strcasecmp(level.mapname, "jail2") == 0) ||
- (Q_strcasecmp(level.mapname, "jail4") == 0) ||
- (Q_strcasecmp(level.mapname, "mine1") == 0) ||
- (Q_strcasecmp(level.mapname, "mine2") == 0) ||
- (Q_strcasecmp(level.mapname, "mine3") == 0) ||
- (Q_strcasecmp(level.mapname, "mine4") == 0) ||
- (Q_strcasecmp(level.mapname, "lab") == 0) ||
- (Q_strcasecmp(level.mapname, "boss1") == 0) ||
- (Q_strcasecmp(level.mapname, "fact3") == 0) ||
- (Q_strcasecmp(level.mapname, "biggun") == 0) ||
- (Q_strcasecmp(level.mapname, "space") == 0) ||
- (Q_strcasecmp(level.mapname, "command") == 0) ||
- (Q_strcasecmp(level.mapname, "power2") == 0) ||
- (Q_strcasecmp(level.mapname, "strike") == 0))
+ if((cistrcmp(level.mapname, "jail2") == 0) ||
+ (cistrcmp(level.mapname, "jail4") == 0) ||
+ (cistrcmp(level.mapname, "mine1") == 0) ||
+ (cistrcmp(level.mapname, "mine2") == 0) ||
+ (cistrcmp(level.mapname, "mine3") == 0) ||
+ (cistrcmp(level.mapname, "mine4") == 0) ||
+ (cistrcmp(level.mapname, "lab") == 0) ||
+ (cistrcmp(level.mapname, "boss1") == 0) ||
+ (cistrcmp(level.mapname, "fact3") == 0) ||
+ (cistrcmp(level.mapname, "biggun") == 0) ||
+ (cistrcmp(level.mapname, "space") == 0) ||
+ (cistrcmp(level.mapname, "command") == 0) ||
+ (cistrcmp(level.mapname, "power2") == 0) ||
+ (cistrcmp(level.mapname, "strike") == 0))
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_FixCoopSpots;
@@ -853,7 +853,7 @@
target = spot->targetname;
if (!target)
target = "";
- if ( Q_strcasecmp(game.spawnpoint, target) == 0 )
+ if ( cistrcmp(game.spawnpoint, target) == 0 )
{ // this is a coop spawn point for one of the clients here
index--;
if (!index)
@@ -890,7 +890,7 @@
if (!game.spawnpoint[0] || !spot->targetname)
continue;
- if (Q_strcasecmp(game.spawnpoint, spot->targetname) == 0)
+ if (cistrcmp(game.spawnpoint, spot->targetname) == 0)
break;
}
--- a/game/q_shared.c
+++ b/game/q_shared.c
@@ -28,10 +28,6 @@
//============================================================================
-#ifdef _WIN32
-#pragma optimize( "", off )
-#endif
-
void RotatePointAroundVector( vec3_t dst, const vec3_t dir, const vec3_t point, float degrees )
{
float m[3][3];
@@ -87,12 +83,6 @@
}
}
-#ifdef _WIN32
-#pragma optimize( "", on )
-#endif
-
-
-
void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
{
float angle;
@@ -919,50 +909,6 @@
for (i=size-1 ; i>0 ; i-=4096)
paged_total += buffer[i];
}
-
-
-
-/*
-============================================================================
-
- LIBRARY REPLACEMENT FUNCTIONS
-
-============================================================================
-*/
-
-
-int Q_strncasecmp (char *s1, char *s2, int n)
-{
- int c1, c2;
-
- do
- {
- c1 = *s1++;
- c2 = *s2++;
-
- if (!n--)
- return 0; // strings are equal until end point
-
- if (c1 != c2)
- {
- if (c1 >= 'a' && c1 <= 'z')
- c1 -= ('a' - 'A');
- if (c2 >= 'a' && c2 <= 'z')
- c2 -= ('a' - 'A');
- if (c1 != c2)
- return -1; // strings not equal
- }
- } while (c1);
-
- return 0; // strings are equal
-}
-
-int Q_strcasecmp (char *s1, char *s2)
-{
- return Q_strncasecmp (s1, s2, 99999);
-}
-
-
void Com_sprintf (char *dest, int size, char *fmt, ...)
{
--- a/mkfile
+++ b/mkfile
@@ -48,7 +48,6 @@
plan9/menu.$O\
plan9/misc.$O\
plan9/snd.$O\
- plan9/so.$O\
plan9/sys.$O\
plan9/udp.$O\
plan9/vid.$O\
--- a/plan9/cd.c
+++ b/plan9/cd.c
@@ -203,13 +203,13 @@
command = Cmd_Argv (1);
- if (Q_strcasecmp(command, "on") == 0)
+ if (cistrcmp(command, "on") == 0)
{
enabled = true;
return;
}
- if (Q_strcasecmp(command, "off") == 0)
+ if (cistrcmp(command, "off") == 0)
{
if (playing)
CDAudio_Stop();
@@ -217,7 +217,7 @@
return;
}
- if (Q_strcasecmp(command, "reset") == 0)
+ if (cistrcmp(command, "reset") == 0)
{
enabled = true;
if (playing)
@@ -228,7 +228,7 @@
return;
}
- if (Q_strcasecmp(command, "remap") == 0)
+ if (cistrcmp(command, "remap") == 0)
{
ret = Cmd_Argc() - 2;
if (ret <= 0)
@@ -243,7 +243,7 @@
return;
}
- if (Q_strcasecmp(command, "close") == 0)
+ if (cistrcmp(command, "close") == 0)
{
CDAudio_CloseDoor();
return;
@@ -259,37 +259,37 @@
}
}
- if (Q_strcasecmp(command, "play") == 0)
+ if (cistrcmp(command, "play") == 0)
{
CDAudio_Play((byte)atoi(Cmd_Argv (2)), false);
return;
}
- if (Q_strcasecmp(command, "loop") == 0)
+ if (cistrcmp(command, "loop") == 0)
{
CDAudio_Play((byte)atoi(Cmd_Argv (2)), true);
return;
}
- if (Q_strcasecmp(command, "stop") == 0)
+ if (cistrcmp(command, "stop") == 0)
{
CDAudio_Stop();
return;
}
- if (Q_strcasecmp(command, "pause") == 0)
+ if (cistrcmp(command, "pause") == 0)
{
CDAudio_Pause();
return;
}
- if (Q_strcasecmp(command, "resume") == 0)
+ if (cistrcmp(command, "resume") == 0)
{
CDAudio_Resume();
return;
}
- if (Q_strcasecmp(command, "eject") == 0)
+ if (cistrcmp(command, "eject") == 0)
{
if (playing)
CDAudio_Stop();
@@ -298,7 +298,7 @@
return;
}
- if (Q_strcasecmp(command, "info") == 0)
+ if (cistrcmp(command, "info") == 0)
{
Com_Printf("%u tracks\n", maxTrack);
if (playing)
--- a/plan9/in.c
+++ b/plan9/in.c
@@ -7,23 +7,28 @@
#include <keyboard.h>
#include "../q_shared.h"
-cvar_t *in_mouse;
-cvar_t *in_joystick;
-cvar_t *m_filter;
-cvar_t *m_windowed;
-cvar_t *sensitivity;
-cvar_t *lookstrafe;
-cvar_t *m_side;
-cvar_t *m_yaw;
-cvar_t *m_pitch;
-cvar_t *m_forward;
-cvar_t *freelook;
+extern int resized; /* vid.c */
+extern Point center;
+extern Channel *fuckchan, *tchan; /* sys.c */
-qboolean mouseon;
-qboolean mlooking;
-int dx, dy;
-int oldmwin;
+cvar_t *in_joystick;
+cvar_t *sensitivity;
+cvar_t *lookstrafe;
+cvar_t *lookspring;
+cvar_t *freelook;
+cvar_t *m_pitch;
+static cvar_t *m_filter;
+static cvar_t *m_windowed;
+static cvar_t *m_yaw;
+static cvar_t *m_side;
+static cvar_t *m_forward;
+
+static int mouseon;
+static int mlooking;
+static int dx, dy;
+static int oldmwin;
+
typedef struct Kev Kev;
struct Kev{
int key;
@@ -30,19 +35,36 @@
int down;
};
enum{
- Nbuf = 64,
- ITHGRP = 2
+ Nbuf = 64
};
-Channel *kchan;
-Channel *mchan;
+static Channel *kchan, *mchan;
+static int iop = -1, pfd[2];
+static QLock killock;
-/* rw_9.c */
-extern int resized;
-extern Point center;
-extern refimport_t ri;
-void IN_Grabm(int on)
+char *
+Sys_ConsoleInput(void)
{
+ static char buf[256];
+ int n;
+
+ if(dedicated != nil && dedicated->value && iop >= 0){
+ if(flen(pfd[1]) < 1) /* only poll for input */
+ return nil;
+ if((n = read(pfd[1], buf, sizeof buf)) < 0)
+ sysfatal("Sys_ConsoleInput:read: %r");
+ if(n == 0){
+ iop = -1;
+ return nil;
+ }
+ return buf;
+ }
+ return nil;
+}
+
+void
+IN_Grabm(int on)
+{
static char nocurs[2*4+2*2*16];
static int fd = -1;
@@ -60,12 +82,14 @@
}
}
-void IN_Commands (void)
+void
+IN_Commands(void)
{
/* joystick stuff */
}
-void btnev (int btn, ulong msec)
+void
+btnev(int btn, ulong msec)
{
static int oldb;
int i, b;
@@ -88,7 +112,8 @@
}
}
-void KBD_Update (void)
+void
+KBD_Update(void)
{
int r;
Kev ev;
@@ -111,9 +136,11 @@
sysfatal("KBD_Update:nbrecv: %r\n");
}
-void IN_Move (usercmd_t *cmd)
+void
+IN_Move(usercmd_t *cmd)
{
- static int mx, my, oldmx, oldmy;
+ static int oldmx, oldmy;
+ int mx, my;
if(!mouseon)
return;
@@ -145,32 +172,38 @@
}
/* called on focus/unfocus in win32 */
-void IN_Activate (qboolean)
+void
+IN_Activate(qboolean)
{
}
/* called every frame even if not generating commands */
-void IN_Frame (void)
+void
+IN_Frame(void)
{
}
-void IN_ForceCenterView (void)
+void
+IN_ForceCenterView(void)
{
cl.viewangles[PITCH] = 0;
}
-void IN_MLookDown (void)
+void
+IN_MLookDown(void)
{
mlooking = true;
}
-void IN_MLookUp (void)
+void
+IN_MLookUp(void)
{
mlooking = false;
IN_CenterView();
}
-int runetokey (Rune r)
+static int
+runetokey(Rune r)
{
int k = 0;
@@ -213,18 +246,20 @@
return k;
}
-void kproc (void *)
+static void
+kproc(void *)
{
int n, k, fd;
- char buf[128], kdown[128] = {0}, *s;
+ char buf[128], kdown[128], *s;
Rune r;
Kev ev;
- if(threadsetgrp(ITHGRP) < 0)
+ if(threadsetgrp(THin) < 0)
sysfatal("kproc:threadsetgrp: %r");
if((fd = open("/dev/kbd", OREAD)) < 0)
sysfatal("open /dev/kbd: %r");
+ kdown[0] = kdown[1] = 0;
while((n = read(fd, buf, sizeof buf)) > 0){
buf[n-1] = 0;
switch(*buf){
@@ -266,13 +301,14 @@
close(fd);
}
-void mproc (void *)
+static void
+mproc(void *)
{
int n, nerr = 0, fd;
char buf[1+5*12];
Mouse m;
- if(threadsetgrp(ITHGRP) < 0)
+ if(threadsetgrp(THin) < 0)
sysfatal("mproc:threadsetgrp: %r");
if((fd = open("/dev/mouse", ORDWR)) < 0)
sysfatal("open /dev/mouse: %r");
@@ -309,10 +345,66 @@
close(fd);
}
-void IN_Shutdown (void)
+static void
+tproc(void *) /* stupid select() timeout bullshit */
{
+ int t, ms, n, r;
+
+ threadsetgrp(THin);
+
+ t = ms = 0;
+ for(;;){
+ sleep(1);
+ t++;
+
+ if((r = nbrecv(tchan, &n)) < 0)
+ sysfatal("tproc:nbrecv: %r");
+ if(r == 0){
+ if(t == ms && nbsend(fuckchan, nil) < 0)
+ sysfatal("tproc:nbsend: %r");
+ continue;
+ }
+ if(n <= 0)
+ ms = 0;
+ else{
+ ms = n;
+ t = 0;
+ }
+ }
+}
+
+static void
+iproc(void *)
+{
+ int n;
+ char s[256];
+
+ threadsetgrp(THin);
+
+ if((iop = pipe(pfd)) < 0)
+ sysfatal("iproc:pipe: %r");
+ for(;;){
+ if((n = read(0, s, sizeof s)) <= 0)
+ break;
+ s[n-1] = 0;
+ if((write(pfd[0], s, n)) != n)
+ break;
+ if(nbsend(fuckchan, nil) < 0)
+ sysfatal("iproc:nbsend: %r");
+ }
+ fprint(2, "iproc %d: %r\n", threadpid(threadid()));
+ iop = -1;
+}
+
+void
+IN_Shutdown(void)
+{
+ qlock(&killock); /* there can be only one */
IN_Grabm(0);
- threadkillgrp(ITHGRP);
+ threadkillgrp(THin);
+ iop = -1;
+ close(pfd[0]);
+ close(pfd[1]);
if(kchan != nil){
chanfree(kchan);
kchan = nil;
@@ -321,25 +413,35 @@
chanfree(mchan);
mchan = nil;
}
+ qunlock(&killock);
}
-void IN_Init (void)
+void
+IN_Init(void)
{
- in_mouse = ri.Cvar_Get("in_mouse", "1", CVAR_ARCHIVE);
- in_joystick = ri.Cvar_Get("in_joystick", "0", CVAR_ARCHIVE);
- m_windowed = ri.Cvar_Get("m_windowed", "0", CVAR_ARCHIVE);
- m_filter = ri.Cvar_Get("m_filter", "0", 0);
- freelook = ri.Cvar_Get("freelook", "0", 0);
- lookstrafe = ri.Cvar_Get("lookstrafe", "0", 0);
- sensitivity = ri.Cvar_Get("sensitivity", "3", 0);
- m_pitch = ri.Cvar_Get("m_pitch", "0.022", 0);
- m_yaw = ri.Cvar_Get("m_yaw", "0.022", 0);
- m_forward = ri.Cvar_Get("m_forward", "1", 0);
- m_side = ri.Cvar_Get("m_side", "0.8", 0);
+ if(dedicated->value){
+ if(proccreate(iproc, nil, 8192) < 0)
+ sysfatal("proccreate iproc: %r");
+ if(proccreate(tproc, nil, 8192) < 0)
+ sysfatal("proccreate tproc: %r");
+ return;
+ }
+ in_joystick = Cvar_Get("in_joystick", "0", CVAR_ARCHIVE);
+ sensitivity = Cvar_Get("sensitivity", "3", CVAR_ARCHIVE);
+ freelook = Cvar_Get("freelook", "0", CVAR_ARCHIVE);
+ lookspring = Cvar_Get("lookspring", "0", CVAR_ARCHIVE);
+ lookstrafe = Cvar_Get("lookstrafe", "0", CVAR_ARCHIVE);
+ m_pitch = Cvar_Get("m_pitch", "0.022", CVAR_ARCHIVE);
- ri.Cmd_AddCommand("+mlook", IN_MLookDown);
- ri.Cmd_AddCommand("-mlook", IN_MLookUp);
- ri.Cmd_AddCommand("force_centerview", IN_ForceCenterView);
+ m_yaw = Cvar_Get("m_yaw", "0.022", 0);
+ m_forward = Cvar_Get("m_forward", "1", 0);
+ m_side = Cvar_Get("m_side", "0.8", 0);
+ m_windowed = Cvar_Get("m_windowed", "0", CVAR_ARCHIVE);
+ m_filter = Cvar_Get("m_filter", "0", 0);
+
+ Cmd_AddCommand("+mlook", IN_MLookDown);
+ Cmd_AddCommand("-mlook", IN_MLookUp);
+ Cmd_AddCommand("force_centerview", IN_ForceCenterView);
if((kchan = chancreate(sizeof(Kev), Nbuf)) == nil)
sysfatal("chancreate kchan: %r");
--- a/plan9/menu.c
+++ b/plan9/menu.c
@@ -3,37 +3,35 @@
#include <stdio.h>
#include "../q_shared.h"
-extern cvar_t *vid_fullscreen;
-extern cvar_t *vid_gamma;
-extern cvar_t *scr_viewsize;
-
extern void M_PopMenu(void);
-menuframework_s vmenu;
-menuslider_s ssizeslide;
-menuslider_s gammaslide;
-menulist_s fullscrbox;
-menuaction_s applyaction;
-menuaction_s defaultsaction;
+static menuframework_s vmenu;
+static menuslider_s ssizeslide, gammaslide;
+static menulist_s fullscrbox;
+static menuaction_s applyaction, defaultsaction;
-void vmssize (void *s)
+void
+vmssize(void *s)
{
Cvar_SetValue("viewsize", ((menuslider_s *)s)->curvalue * 10);
}
-void vmgamma (void *s)
+void
+vmgamma(void *s)
{
// invert sense so greater = brighter, and scale to a range of 0.5 to 1.3
Cvar_SetValue("vid_gamma", 0.8 - (((menuslider_s *)s)->curvalue/10.0 - 0.5) + 0.5);
}
-void vmreset (void *)
+void
+vmreset(void *)
{
VID_MenuInit();
}
-void vmapply (void *)
+void
+vmapply(void *)
{
Cvar_SetValue("vid_gamma", 0.8 - (gammaslide.curvalue/10.0 - 0.5) + 0.5);
Cvar_SetValue("vid_fullscreen", fullscrbox.curvalue);
@@ -40,7 +38,8 @@
M_ForceMenuOff();
}
-void VID_MenuInit (void)
+void
+VID_MenuInit(void)
{
static char *yesno[] = {"no", "yes", nil};
@@ -97,12 +96,13 @@
vmenu.x -= 8;
}
-void VID_MenuDraw (void)
+void
+VID_MenuDraw(void)
{
int w, h;
- re.DrawGetPicSize(&w, &h, "m_banner_video");
- re.DrawPic(vid.width/2 - w/2, vid.height/2 - 110, "m_banner_video");
+ Draw_GetPicSize(&w, &h, "m_banner_video");
+ Draw_Pic(vid.width/2 - w/2, vid.height/2 - 110, "m_banner_video");
Menu_AdjustCursor(&vmenu, 1); // starting position
Menu_Draw(&vmenu);
}
--- a/plan9/misc.c
+++ b/plan9/misc.c
@@ -3,19 +3,20 @@
#include <stdio.h>
#include "../q_shared.h"
-byte *membase;
-int maxhunksize;
-int curhunksize;
int curtime;
-char findbase[MAX_OSPATH], findpath[MAX_OSPATH], findpattern[MAX_OSPATH];
-long dirn, di;
-Dir *dirs;
-int glob_match(char *, char *);
+static uchar *membase;
+static int maxhunksize, curhunksize;
+static char findbase[MAX_OSPATH], findpath[MAX_OSPATH], findpattern[MAX_OSPATH];
+static Dir *dirs;
+static long dirn, di;
+static int glob_match(char *, char *);
+
/* Like glob_match, but match PATTERN against any final segment of TEXT. */
-int glob_match_after_star(char *pattern, char *text)
+static int
+glob_match_after_star(char *pattern, char *text)
{
char *p = pattern, *t = text;
char c, c1;
@@ -41,7 +42,8 @@
}
/* Return nonzero if PATTERN has any special globbing chars in it. */
-int glob_pattern_p(char *pattern)
+static int
+glob_pattern_p(char *pattern)
{
char *p = pattern;
char c;
@@ -87,7 +89,8 @@
and match the character exactly, precede it with a `\'.
*/
-int glob_match(char *pattern, char *text)
+static int
+glob_match(char *pattern, char *text)
{
char *p = pattern, *t = text;
char c, c1, cstart, cend;
@@ -176,7 +179,8 @@
return *t == '\0';
}
-void *Hunk_Begin (int maxsize)
+void *
+Hunk_Begin(int maxsize)
{
// reserve a huge chunk of memory, but don't commit any yet
maxhunksize = maxsize;
@@ -186,7 +190,8 @@
return membase;
}
-void *Hunk_Alloc (int size)
+void *
+Hunk_Alloc(int size)
{
byte *buf;
@@ -199,7 +204,8 @@
return buf;
}
-int Hunk_End (void)
+int
+Hunk_End(void)
{
if(realloc(membase, curhunksize) != membase)
sysfatal("Hunk_End:realloc: %r");
@@ -206,13 +212,15 @@
return curhunksize;
}
-void Hunk_Free (void *base)
+void
+Hunk_Free(void *base)
{
if(base != nil)
free(base);
}
-int Sys_Milliseconds (void)
+int
+Sys_Milliseconds(void)
{
static long msbase;
@@ -222,7 +230,8 @@
return curtime;
}
-void Sys_Mkdir (char *path)
+void
+Sys_Mkdir(char *path)
{
int d;
@@ -232,7 +241,8 @@
close(d);
}
-qboolean CompareAttributes (ulong m, uint musthave, uint canthave)
+static qboolean
+CompareAttributes(ulong m, uint musthave, uint canthave)
{
if(m & DMDIR && canthave & SFF_SUBDIR)
return false;
@@ -241,7 +251,8 @@
return true;
}
-char *Sys_FindFirst (char *path, uint musthave, uint canhave)
+char *
+Sys_FindFirst(char *path, uint musthave, uint canhave)
{
char *p;
int fd;
@@ -279,7 +290,8 @@
return Sys_FindNext (musthave, canhave);
}
-char *Sys_FindNext (uint musthave, uint canhave)
+char *
+Sys_FindNext(uint musthave, uint canhave)
{
int i;
@@ -298,7 +310,8 @@
return nil;
}
-void Sys_FindClose (void)
+void
+Sys_FindClose(void)
{
if(dirs != nil){
free(dirs);
--- a/plan9/snd.c
+++ b/plan9/snd.c
@@ -4,41 +4,44 @@
#include <thread.h>
#include "../q_shared.h"
-int sndon;
+static cvar_t *sndbits;
+static cvar_t *sndspeed;
+static cvar_t *sndchannels;
+static cvar_t *snddev;
+static int afd, sndon, wpos;
enum{
Nbuf = 32
};
-int audio_fd;
-int wpos;
-int stid = -1;
-Channel *schan;
+static Channel *schan;
+static QLock sndlock;
-cvar_t *sndbits;
-cvar_t *sndspeed;
-cvar_t *sndchannels;
-cvar_t *snddevice;
-
-void sproc (void *)
+static void
+sproc(void *)
{
int n;
+ threadsetgrp(THsnd);
+
for(;;){
if(recv(schan, nil) < 0){
fprint(2, "sproc:recv %r\n");
break;
}
- if((n = write(audio_fd, dma.buffer, dma.samplebits/8 * dma.samples)) < 0){
+ if((n = write(afd, dma.buffer, dma.samplebits/8 * dma.samples)) < 0){
fprint(2, "sproc:write %r\n");
break;
}
+ qlock(&sndlock);
wpos += n;
+ qunlock(&sndlock);
}
- stid = -1;
+ fprint(2, "sproc %d: %r\n", threadpid(threadid()));
}
-qboolean SNDDMA_Init(void)
+qboolean
+SNDDMA_Init(void)
{
if(sndon)
return false;
@@ -46,14 +49,14 @@
if(COM_CheckParm("-nosound"))
return false;
- if(!snddevice){
+ if(snddev == nil){
sndbits = Cvar_Get("sndbits", "16", CVAR_ARCHIVE);
sndspeed = Cvar_Get("sndspeed", "44100", CVAR_ARCHIVE);
sndchannels = Cvar_Get("sndchannels", "2", CVAR_ARCHIVE);
- snddevice = Cvar_Get("snddevice", "/dev/audio", CVAR_ARCHIVE);
+ snddev = Cvar_Get("snddev", "/dev/audio", CVAR_ARCHIVE);
}
- if((audio_fd = open(snddevice->string, OWRITE)) < 0){
+ if((afd = open(snddev->string, OWRITE)) < 0){
fprint(2, "SNDDMA_Init:open %r\n");
return false;
}
@@ -73,10 +76,10 @@
sysfatal("SNDDMA_Init:mallocz: %r\n");
dma.samplepos = 0;
sndon = 1;
+ wpos = 0;
schan = chancreate(sizeof(int), Nbuf);
- if((stid = proccreate(sproc, nil, 8192)) < 0){
- stid = -1;
+ if(proccreate(sproc, nil, 8192) < 0){
SNDDMA_Shutdown();
sysfatal("SNDDMA_Init:proccreate: %r\n");
}
@@ -83,32 +86,35 @@
return true;
}
-int SNDDMA_GetDMAPos(void)
+int
+SNDDMA_GetDMAPos(void)
{
if(!sndon)
return 0;
+ qlock(&sndlock);
dma.samplepos = wpos / (dma.samplebits/8);
+ qunlock(&sndlock);
return dma.samplepos;
}
-void SNDDMA_Shutdown(void)
+void
+SNDDMA_Shutdown(void)
{
if(!sndon)
return;
- if(stid != -1){
- threadkill(stid);
- stid = -1;
- }
+
+ threadkillgrp(THsnd);
+ close(afd);
if(schan != nil){
chanfree(schan);
schan = nil;
}
free(dma.buffer);
- close(audio_fd);
sndon = 0;
}
-void SNDDMA_Submit(void)
+void
+SNDDMA_Submit(void)
{
if(nbsend(schan, nil) < 0){
fprint(2, "SNDDMA_Submit:nbsend: %r\n");
@@ -116,6 +122,7 @@
}
}
-void SNDDMA_BeginPainting (void)
+void
+SNDDMA_BeginPainting(void)
{
}
--- a/plan9/so.c
+++ /dev/null
@@ -1,77 +1,0 @@
-#include <u.h>
-#include <libc.h>
-#include <stdio.h>
-#include "../q_shared.h"
-
-refexport_t GetRefAPI(refimport_t);
-
-cvar_t *vid_gamma;
-cvar_t *vid_ref; // Name of Refresh DLL loaded
-cvar_t *vid_xpos; // X coordinate of window position
-cvar_t *vid_ypos; // Y coordinate of window position
-cvar_t *vid_fullscreen;
-refexport_t re; /* exported functions from refresh DLL */
-
-
-void VID_Printf (int print_level, char *fmt, ...)
-{
- va_list argptr;
- char msg[4096];
-
- va_start(argptr, fmt);
- vsprintf(msg, fmt, argptr);
- va_end(argptr);
- if(print_level == PRINT_ALL)
- Com_Printf("%s", msg);
- else
- Com_DPrintf("%s", msg);
-}
-
-void VID_Error (int err_level, char *fmt, ...)
-{
- va_list argptr;
- char msg[4096];
-
- va_start(argptr, fmt);
- vsprintf(msg, fmt, argptr);
- va_end(argptr);
- Com_Error(err_level, "%s", msg);
-}
-
-void VID_CheckChanges (void)
-{
-}
-
-void VID_Shutdown (void)
-{
- re.Shutdown();
-}
-
-void VID_Init (void)
-{
- refimport_t ri;
-
- vid_ref = Cvar_Get("vid_ref", "libdraw", CVAR_ARCHIVE);
- vid_xpos = Cvar_Get("vid_xpos", "3", CVAR_ARCHIVE);
- vid_ypos = Cvar_Get("vid_ypos", "22", CVAR_ARCHIVE);
- vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
- vid_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE);
-
- ri.Cmd_AddCommand = Cmd_AddCommand;
- ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
- ri.Cmd_Argc = Cmd_Argc;
- ri.Cmd_Argv = Cmd_Argv;
- ri.Cmd_ExecuteText = Cbuf_ExecuteText;
- ri.Con_Printf = VID_Printf;
- ri.Sys_Error = VID_Error;
- ri.FS_LoadFile = FS_LoadFile;
- ri.FS_FreeFile = FS_FreeFile;
- ri.FS_Gamedir = FS_Gamedir;
- ri.Cvar_Get = Cvar_Get;
- ri.Cvar_Set = Cvar_Set;
- ri.Cvar_SetValue = Cvar_SetValue;
- ri.Vid_MenuInit = VID_MenuInit;
-
- re = GetRefAPI(ri);
- re.Init(nil, nil);
-}
--- a/plan9/sys.c
+++ b/plan9/sys.c
@@ -5,39 +5,27 @@
#include <thread.h>
#include "../q_shared.h"
-mainstacksize = 512*1024; /* FIXME */
-
+mainstacksize = 512*1024;
uint sys_frame_time;
-qboolean stdin_active = true;
+Channel *fuckchan, *tchan;
void KBD_Update(void);
/* prints to "debugging console" */
-void Sys_ConsoleOutput (char *string)
+void
+Sys_ConsoleOutput(char *s)
{
- write(1, string, strlen(string));
+ write(1, s, strlen(s));
}
-void Sys_Quit (void)
-{
- CL_Shutdown();
- Qcommon_Shutdown();
- threadexitsall(nil);
-}
-
-void Sys_Init(void)
-{
- //Sys_SetFPCW();
-}
-
-void Sys_Error (char *error, ...)
+void
+Sys_Error(char *error, ...)
{
char buf[1024], *out;
va_list arg;
CL_Shutdown();
- Qcommon_Shutdown();
va_start(arg, error);
out = vseprint(buf, buf+sizeof(buf), error, arg);
@@ -47,62 +35,79 @@
sysfatal("ending.");
}
-int Sys_FileTime (char *path)
+vlong
+flen(int fd)
{
- uchar sb[1024];
+ uchar bs[1024];
- if(stat(path, sb, sizeof sb) < 0){
- fprint(2, "Sys_FileTime:stat: %r\n");
+ if(fstat(fd, bs, sizeof bs) < 0){
+ fprint(2, "flen:fstat: %r\n");
return -1;
}
- return *((int *)(sb+25));
+ return *((vlong *)(bs+2+2+4+1+4+8+4+4+4)); /* length[8] */
}
-char *Sys_ConsoleInput(void)
+int
+Sys_FileTime(char *path)
{
- static char text[256];
- int n;
+ uchar sb[1024];
- if(!dedicated || !dedicated->value || !stdin_active)
- return nil;
-
- if((n = read(0, text, sizeof(text))) < 0)
- return nil;
- if(n == 0){
- stdin_active = false;
- return nil;
+ if(stat(path, sb, sizeof sb) < 0){
+ fprint(2, "Sys_FileTime:stat: %r\n");
+ return -1;
}
- text[n-1] = '\0'; /* rip off \n */
- return text;
+ return *((int *)(sb+25));
}
-void Sys_UnloadGame (void)
+void
+Sys_UnloadGame(void)
{
}
-void Sys_AppActivate (void)
+void
+Sys_AppActivate(void)
{
}
-void Sys_SendKeyEvents (void)
+void
+Sys_SendKeyEvents(void)
{
-#ifndef DEDICATED_ONLY
KBD_Update();
-#endif
sys_frame_time = Sys_Milliseconds(); // grab frame time
}
-char *Sys_GetClipboardData (void)
+char *
+Sys_GetClipboardData(void)
{
return nil;
}
-void Sys_CopyProtect (void)
+void
+Sys_CopyProtect(void)
{
}
-void croak (void *, char *note)
+void
+Sys_Quit(void)
{
+ chanfree(fuckchan);
+ chanfree(tchan);
+ threadexitsall(nil);
+}
+
+void
+Sys_Init(void)
+{
+ //Sys_SetFPCW();
+ if((fuckchan = chancreate(sizeof(int), 1)) == nil)
+ sysfatal("chancreate fuckchan: %r");
+ if((tchan = chancreate(sizeof(int), 16)) == nil)
+ sysfatal("chancreate tchan: %r");
+}
+
+void
+croak(void *, char *note)
+{
if(!strncmp(note, "sys:", 4)){
IN_Shutdown();
SNDDMA_Shutdown();
@@ -111,7 +116,8 @@
noted(NDFLT);
}
-void threadmain (int argc, char *argv[])
+void
+threadmain(int argc, char *argv[])
{
int time, oldtime, newtime;
--- a/plan9/udp.c
+++ b/plan9/udp.c
@@ -9,11 +9,13 @@
/* FIXME: this shit SUCKS, and ipv4 only because of other code */
-cvar_t *svport; /* server port and copy of string value */
-char srv[6];
-cvar_t *clport; /* "client" port and copy */
-char clsrv[6];
+extern Channel *fuckchan, *tchan;
+static cvar_t *svport; /* server port and copy of string value */
+static char srv[6];
+static cvar_t *clport; /* "client" port and copy */
+static char clsrv[6];
+
typedef struct Loopmsg Loopmsg;
typedef struct Loopback Loopback;
typedef struct Conmsg Conmsg;
@@ -20,11 +22,10 @@
typedef struct Conlist Conlist;
enum{
+ Hdrsz = 16+16+16+2+2, /* sizeof Udphdr w/o padding */
+ Bufsz = MAX_MSGLEN,
+ Nbuf = 64,
MAX_LOOPBACK = 4,
- HDRSZ = 16+16+16+2+2, /* sizeof Udphdr w/o padding */
- BUFSZ = MAX_MSGLEN,
- NBUF = 64,
- DTHGRP = 1,
CLPORT = 27909
};
struct Loopmsg{
@@ -36,7 +37,7 @@
int get;
int send;
};
-Loopback loopbacks[2];
+static Loopback loopbacks[2];
struct Conlist{
Conlist *p;
@@ -46,28 +47,29 @@
Udphdr h;
int src; /* q2 assumes broadcast replies are received on NS_CLIENT */
};
-Conlist *cnroot;
+static Conlist *cnroot;
struct Conmsg{
Conlist *p;
int n;
- uchar buf[BUFSZ];
+ uchar buf[Bufsz];
};
-Channel *udpchan;
-Channel *clchan;
+static Channel *udpchan, *clchan;
-netadr_t laddr; /* 0.0.0.0:0 */
-int cfd = -1, ufd = -1, clfd = -1, cldfd = -1;
-QLock cnlock;
+static netadr_t laddr; /* 0.0.0.0:0 */
+static int cfd = -1, ufd = -1, clfd = -1, cldfd = -1;
+static QLock cnlock;
-qboolean NET_CompareAdr (netadr_t a, netadr_t b)
+qboolean
+NET_CompareAdr(netadr_t a, netadr_t b)
{
- return (a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port);
+ return(a.ip[0] == b.ip[0] && a.ip[1] == b.ip[1] && a.ip[2] == b.ip[2] && a.ip[3] == b.ip[3] && a.port == b.port);
}
/* compares without the port */
-qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b)
+qboolean
+NET_CompareBaseAdr(netadr_t a, netadr_t b)
{
if(a.type != b.type)
return false;
@@ -83,7 +85,8 @@
}
}
-char *NET_AdrToString (netadr_t a)
+char *
+NET_AdrToString(netadr_t a)
{
static char s[256];
@@ -91,7 +94,8 @@
return s;
}
-char *NET_BaseAdrToString (netadr_t a)
+char *
+NET_BaseAdrToString(netadr_t a)
{
static char s[256];
@@ -110,12 +114,12 @@
192.246.40.70:28000
=============
*/
-qboolean NET_StringToAdr (char *addr, netadr_t *a) /* assumes IPv4 */
+qboolean
+NET_StringToAdr(char *addr, netadr_t *a) /* assumes IPv4 */
{
int i;
char s[256], *p, *pp;
- Ndb *db;
- Ndbtuple *nt;
+ Ndbtuple *t, *nt;
if(!strcmp(addr, "localhost")){
memset(a, 0, sizeof *a);
@@ -126,24 +130,25 @@
strncpy(s, addr, sizeof s);
s[sizeof(s)-1] = 0;
+ /* FIXME: arbitrary length strings */
if((p = strrchr(s, ':')) != nil){
*p++ = '\0';
a->port = BigShort(atoi(p));
}
- if((db = ndbopen(nil)) == nil){
- fprint(2, "NET_StringToAdr:ndbopen: %r\n");
- return false;
+ if((t = dnsquery(nil, s, "ip")) == nil){
+ fprint(2, "NET_StringToAdr:dnsquery %s: %r\n", s);
+ return 0;
}
- if((nt = ndbgetipaddr(db, s)) == nil){
- ndbclose(db);
- fprint(2, "NET_StringToAdr:ndbgetipaddr: %r\n");
- return false;
- }
- strncpy(s, nt->val, sizeof(s)-1); /* just look at first value found */
- ndbfree(nt);
- ndbclose(db);
+ for(nt = t; nt != nil; nt = nt->entry)
+ if(!strcmp(nt->attr, "ip")){
+ strncpy(s, nt->val, sizeof(s)-1);
+ break;
+ }
+ ndbfree(t);
+
+ /* FIXMEGASHIT */
for(i = 0, pp = s; i < IPv4addrlen; i++){
if((p = strchr(pp, '.')) != nil)
*p++ = '\0';
@@ -154,12 +159,14 @@
return true;
}
-qboolean NET_IsLocalAddress (netadr_t adr)
+qboolean
+NET_IsLocalAddress(netadr_t adr)
{
return NET_CompareAdr(adr, laddr);
}
-qboolean looprecv (netsrc_t sock, netadr_t *net_from, sizebuf_t *d)
+static int
+looprecv(netsrc_t sock, netadr_t *net_from, sizebuf_t *d)
{
int i;
Loopback *l;
@@ -168,7 +175,7 @@
if(l->send - l->get > MAX_LOOPBACK)
l->get = l->send - MAX_LOOPBACK;
if(l->get >= l->send)
- return false;
+ return 0;
i = l->get & (MAX_LOOPBACK-1);
l->get++;
@@ -175,10 +182,11 @@
memcpy(d->data, l->msgs[i].data, l->msgs[i].datalen);
d->cursize = l->msgs[i].datalen;
*net_from = laddr;
- return true;
+ return 1;
}
-void loopsend (netsrc_t sock, int length, void *data, netadr_t /*to*/)
+static void
+loopsend(netsrc_t sock, int length, void *data, netadr_t /*to*/)
{
Loopback *l;
int i;
@@ -190,7 +198,8 @@
l->msgs[i].datalen = length;
}
-void cninit (void)
+static void
+cninit(void)
{
if(cnroot != nil)
return;
@@ -202,7 +211,8 @@
cnroot->dfd = -1;
}
-Conlist *cnins (int fd, char *addr, uchar *u, Udphdr *h, int src)
+static Conlist *
+cnins(int fd, char *addr, uchar *u, Udphdr *h, int src)
{
Conlist *p, *l;
@@ -221,7 +231,8 @@
return p;
}
-Conlist *cnfind (char *raddr)
+static Conlist *
+cnfind(char *raddr)
{
Conlist *p = cnroot->p;
@@ -233,7 +244,8 @@
return nil;
}
-void cndel (Conlist *p)
+static void
+cndel(Conlist *p)
{
Conlist *l = cnroot;
@@ -248,7 +260,8 @@
free(p);
}
-void cnnuke (void)
+static void
+cnnuke(void)
{
Conlist *p, *l = cnroot;
@@ -264,7 +277,8 @@
cnroot = nil;
}
-void dproc (void *me)
+static void
+dproc(void *me)
{
int n, fd;
Conmsg m;
@@ -271,8 +285,7 @@
Conlist *p;
Channel *c;
- if(threadsetgrp(DTHGRP) < 0)
- sysfatal("dproc:threadsetgrp: %r");
+ threadsetgrp(THnet);
m.p = p = me;
c = p->src == NS_CLIENT ? clchan : udpchan;
@@ -283,23 +296,25 @@
break;
m.n = n;
if(send(c, &m) < 0)
- sysfatal("uproc:send: %r\n");
+ sysfatal("uproc:send: %r");
+ if(nbsend(fuckchan, nil) < 0)
+ sysfatal("uproc:nbsend; %r");
}
fprint(2, "dproc %d: %r\n", threadpid(threadid()));
cndel(me);
}
-void uproc (void *c)
+static void
+uproc(void *c)
{
int n, fd;
- uchar udpbuf[BUFSZ+HDRSZ], u[IPaddrlen+2];
+ uchar udpbuf[Bufsz+Hdrsz], u[IPaddrlen+2];
char a[IPaddrlen*2+8+6];
Udphdr h;
Conmsg m;
Conlist *p;
- if(threadsetgrp(DTHGRP) < 0)
- sysfatal("uproc:threadsetgrp: %r");
+ threadsetgrp(THnet);
fd = ufd;
if(c == clchan)
@@ -306,8 +321,8 @@
fd = cldfd;
for(;;){
if((n = read(fd, udpbuf, sizeof udpbuf)) <= 0)
- sysfatal("uproc:read: %r\n");
- memcpy(&h, udpbuf, HDRSZ);
+ sysfatal("uproc:read: %r");
+ memcpy(&h, udpbuf, Hdrsz);
memcpy(u, h.raddr, IPaddrlen);
memcpy(u+IPaddrlen, h.rport, 2);
@@ -318,19 +333,22 @@
qunlock(&cnlock);
m.p = p;
- if(n - HDRSZ < 0){ /* FIXME */
+ if(n - Hdrsz < 0){ /* FIXME */
m.n = n;
memcpy(m.buf, udpbuf, m.n);
}else{
- m.n = n - HDRSZ;
- memcpy(m.buf, udpbuf+HDRSZ, m.n);
+ m.n = n - Hdrsz;
+ memcpy(m.buf, udpbuf+Hdrsz, m.n);
}
if(send(c, &m) < 0)
- sysfatal("uproc:send: %r\n");
+ sysfatal("uproc:send: %r");
+ if(nbsend(fuckchan, nil) < 0)
+ sysfatal("uproc:nbsend: %r");
}
}
-qboolean NET_GetPacket (netsrc_t src, netadr_t *from, sizebuf_t *d)
+qboolean
+NET_GetPacket(netsrc_t src, netadr_t *from, sizebuf_t *d)
{
int n;
Conmsg m;
@@ -357,11 +375,12 @@
return true;
}
-void NET_SendPacket (netsrc_t src, int length, void *data, netadr_t to)
+void
+NET_SendPacket(netsrc_t src, int length, void *data, netadr_t to)
{
int fd;
char *addr, *s, *lport;
- uchar b[BUFSZ+HDRSZ], u[IPaddrlen+2];
+ uchar b[Bufsz+Hdrsz], u[IPaddrlen+2];
Conlist *p;
switch(to.type){
@@ -393,9 +412,9 @@
if(p != nil){
fd = p->dfd;
if(fd == ufd || fd == cldfd){
- memcpy(b, &p->h, HDRSZ);
- memcpy(b+HDRSZ, data, length);
- write(fd, b, length+HDRSZ);
+ memcpy(b, &p->h, Hdrsz);
+ memcpy(b+Hdrsz, data, length);
+ write(fd, b, length+Hdrsz);
break;
}
}else{
@@ -425,17 +444,23 @@
}
}
-/* sleeps msec or until data is read from dfd */
-void NET_Sleep (int msec)
+void
+NET_Sleep(int ms) /* sleep for ms, or wakeup for stdio or incoming packets */
{
if(cfd == -1 || dedicated != nil && !dedicated->value)
return; // we're not a server, just run full speed
- /* FIXME */
- print("NET_Sleep %d: PORTME\n", msec);
+ if(send(tchan, &ms) < 0)
+ sysfatal("NET_Sleep:send: %r");
+ if(recv(fuckchan, nil) < 0)
+ sysfatal("NET_Sleep:recv: %r");
+ ms = -1;
+ if(nbsend(tchan, &ms) < 0) /* stop timer */
+ sysfatal("NET_Sleep:nbsend: %r");
}
-int openname (char *port, int *dfd, Channel **c)
+static int
+openname(char *port, int *dfd, Channel **c)
{
int fd;
char data[64], adir[40];
@@ -447,14 +472,15 @@
snprint(data, sizeof data, "%s/data", adir);
if((*dfd = open(data, ORDWR)) < 0)
sysfatal("openname:open %r");
- if((*c = chancreate(sizeof(Conmsg), NBUF)) == nil)
+ if((*c = chancreate(sizeof(Conmsg), Nbuf)) == nil)
sysfatal("openname:chancreate: %r");
- if(proccreate(uproc, *c, 8196) < 0)
+ if(proccreate(uproc, *c, 8192) < 0)
sysfatal("openname:proccreate: %r");
return fd;
}
-void openudp (void)
+static void
+openudp(void)
{
if(cfd != -1)
return;
@@ -476,10 +502,11 @@
}
/* a single player game will only use the loopback code */
-void NET_Config (qboolean multiplayer)
+void
+NET_Config(qboolean multiplayer)
{
if(!multiplayer){ /* shut down existing udp connections */
- threadkillgrp(DTHGRP);
+ threadkillgrp(THnet);
cnnuke();
if(udpchan != nil){
chanfree(udpchan);
@@ -511,13 +538,15 @@
}
}
-void NET_Shutdown (void)
+void
+NET_Shutdown(void)
{
NET_Config(false);
}
-void NET_Init (void)
+void
+NET_Init(void)
{
- svport = Cvar_Get("port", va("%d", PORT_SERVER), CVAR_NOSET);
- clport = Cvar_Get("clport", va("%hud", CLPORT), CVAR_NOSET);
+ svport = Cvar_Get("port", va("%hu", PORT_SERVER), CVAR_NOSET);
+ clport = Cvar_Get("clport", va("%hu", CLPORT), CVAR_NOSET);
}
--- a/plan9/vid.c
+++ b/plan9/vid.c
@@ -5,20 +5,25 @@
#include <ctype.h>
#include "../q_shared.h"
-qboolean rwon;
-uchar *framebuf;
-Image *fbim;
+refexport_t re; /* exported functions from refresh DLL */
int resized;
Point center;
typedef ulong PIXEL;
-PIXEL st2d_8to24table[256];
-int shiftmask_fl;
-int r_shift, g_shift, b_shift;
-uint r_mask, g_mask, b_mask;
+static int rwon;
+static uchar *framebuf;
+static Image *fbim;
+static PIXEL st2d_8to24table[256];
+static int shiftmask_fl;
+static int r_shift, g_shift, b_shift;
+static uint r_mask, g_mask, b_mask;
-void shiftmask_init (void)
+refexport_t GetRefAPI(refimport_t);
+
+
+static void
+shiftmask_init(void)
{
uint x;
@@ -34,7 +39,8 @@
shiftmask_fl = 1;
}
-PIXEL rgb24 (int r, int g, int b)
+static PIXEL
+rgb24(int r, int g, int b)
{
PIXEL p = 0;
@@ -62,7 +68,8 @@
return p;
}
-void st3_fixup (void)
+static void
+st3_fixup(void)
{
int x, y;
uchar *src;
@@ -90,7 +97,8 @@
}
}
-void resetfb (void)
+static void
+resetfb(void)
{
vid.width = Dx(screen->r);
vid.height = Dy(screen->r);
@@ -112,7 +120,8 @@
sw_mode->modified = true; /* make ref_soft refresh its shit */
}
-int SWimp_Init (void */*hInstance*/, void */*wndProc*/)
+int
+SWimp_Init(void *, void *)
{
srand(getpid());
@@ -119,12 +128,13 @@
if(initdraw(nil, nil, "quake2") < 0)
sysfatal("VID_Init:initdraw: %r\n");
resetfb();
- rwon = true;
- return true;
+ rwon = 1;
+ return 1;
}
/* copy backbuffer to front buffer */
-void SWimp_EndFrame (void)
+void
+SWimp_EndFrame(void)
{
if(resized){ /* skip frame if window resizes */
resized = 0;
@@ -139,13 +149,15 @@
flushimage(display, 1);
}
-rserr_t SWimp_SetMode (int */*pwidth*/, int */*pheight*/, int /*mode*/, qboolean /*fullscreen*/)
+rserr_t
+SWimp_SetMode(int */*pwidth*/, int */*pheight*/, int /*mode*/, qboolean /*fullscreen*/)
{
return rserr_ok;
}
/* nil palette == use existing; palette is expected to be in padded 4-byte xRGB format */
-void SWimp_SetPalette (uchar *palette)
+void
+SWimp_SetPalette(uchar *palette)
{
int i;
@@ -157,7 +169,8 @@
st2d_8to24table[i] = rgb24(palette[i*4], palette[i*4+1], palette[i*4+2]);
}
-void SWimp_Shutdown (void)
+void
+SWimp_Shutdown(void)
{
if(!rwon)
return;
@@ -165,9 +178,72 @@
free(framebuf);
if(fbim != nil)
freeimage(fbim);
- rwon = false;
+ rwon = 0;
}
-void SWimp_AppActivate (qboolean /*active*/)
+void
+SWimp_AppActivate(qboolean /*active*/)
{
+}
+
+void
+VID_Printf(int print_level, char *fmt, ...)
+{
+ va_list argptr;
+ char msg[4096];
+
+ va_start(argptr, fmt);
+ vsprintf(msg, fmt, argptr);
+ va_end(argptr);
+ if(print_level == PRINT_ALL)
+ Com_Printf("%s", msg);
+ else
+ Com_DPrintf("%s", msg);
+}
+
+void
+VID_Error(int err_level, char *fmt, ...)
+{
+ va_list argptr;
+ char msg[4096];
+
+ va_start(argptr, fmt);
+ vsprintf(msg, fmt, argptr);
+ va_end(argptr);
+ Com_Error(err_level, "%s", msg);
+}
+
+void
+VID_CheckChanges(void)
+{
+}
+
+void
+VID_Shutdown(void)
+{
+ R_Shutdown();
+}
+
+void
+VID_Init(void)
+{
+ refimport_t ri;
+
+ ri.Cmd_AddCommand = Cmd_AddCommand;
+ ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
+ ri.Cmd_Argc = Cmd_Argc;
+ ri.Cmd_Argv = Cmd_Argv;
+ ri.Cmd_ExecuteText = Cbuf_ExecuteText;
+ ri.Con_Printf = VID_Printf;
+ ri.Sys_Error = VID_Error;
+ ri.FS_LoadFile = FS_LoadFile;
+ ri.FS_FreeFile = FS_FreeFile;
+ ri.FS_Gamedir = FS_Gamedir;
+ ri.Cvar_Get = Cvar_Get;
+ ri.Cvar_Set = Cvar_Set;
+ ri.Cvar_SetValue = Cvar_SetValue;
+ ri.Vid_MenuInit = VID_MenuInit;
+
+ re = GetRefAPI(ri);
+ re.Init(nil, nil);
}
--- a/q_shared.h
+++ b/q_shared.h
@@ -20,8 +20,6 @@
// q_shared.h -- included first by ALL program modules
-#pragma pack on /* FIXME: amd64 workaround for structs assumed aligned to 4 bytes */
-
//#define id386
typedef unsigned char byte;
@@ -179,12 +177,6 @@
//=============================================
-// portable case insensitive compare
-int Q_strcasecmp (char *s1, char *s2);
-int Q_strncasecmp (char *s1, char *s2, int n);
-
-//=============================================
-
short BigShort(short l);
short LittleShort(short l);
int BigLong (int l);
@@ -221,6 +213,7 @@
int Sys_Milliseconds (void);
void Sys_Mkdir (char *path);
+vlong flen(int);
// large block stack allocation routines
void *Hunk_Begin (int maxsize);
--- a/qcommon/cmd.c
+++ b/qcommon/cmd.c
@@ -825,7 +825,7 @@
// check functions
for (cmd=cmd_functions ; cmd ; cmd=cmd->next)
{
- if (!Q_strcasecmp (cmd_argv[0],cmd->name))
+ if (!cistrcmp (cmd_argv[0],cmd->name))
{
if (!cmd->function)
{ // forward to server command
@@ -840,7 +840,7 @@
// check alias
for (a=cmd_alias ; a ; a=a->next)
{
- if (!Q_strcasecmp (cmd_argv[0], a->name))
+ if (!cistrcmp (cmd_argv[0], a->name))
{
if (++alias_count == ALIAS_LOOP_COUNT)
{
--- a/qcommon/cmodel.c
+++ b/qcommon/cmodel.c
@@ -1446,9 +1446,6 @@
rotating entities
==================
*/
-#ifdef _WIN32
-#pragma optimize( "", off )
-#endif
trace_t CM_TransformedBoxTrace (vec3_t start, vec3_t end,
@@ -1510,12 +1507,6 @@
return trace;
}
-
-#ifdef _WIN32
-#pragma optimize( "", on )
-#endif
-
-
/*
===============================================================================
--- a/qcommon/common.c
+++ b/qcommon/common.c
@@ -1579,12 +1579,3 @@
all, sv, gm, cl, rf);
}
}
-
-/*
-=================
-Qcommon_Shutdown
-=================
-*/
-void Qcommon_Shutdown (void)
-{
-}
--- a/qcommon/files.c
+++ b/qcommon/files.c
@@ -236,7 +236,7 @@
// look through all the pak file elements
pak = search->pack;
for (i=0 ; i<pak->numfiles ; i++)
- if (!Q_strcasecmp (pak->files[i].name, filename))
+ if (!cistrcmp (pak->files[i].name, filename))
{ // found it!
file_from_pak = 1;
Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
@@ -309,7 +309,7 @@
pak = search->pack;
for (i=0 ; i<pak->numfiles ; i++)
- if (!Q_strcasecmp (pak->files[i].name, filename))
+ if (!cistrcmp (pak->files[i].name, filename))
{ // found it!
file_from_pak = 1;
Com_DPrintf ("PackFile: %s : %s\n",pak->filename, filename);
--- a/qcommon/qcommon.h
+++ b/qcommon/qcommon.h
@@ -761,7 +761,6 @@
void Qcommon_Init (int argc, char **argv);
void Qcommon_Frame (int msec);
-void Qcommon_Shutdown (void);
#define NUMVERTEXNORMALS 162
extern vec3_t bytedirs[NUMVERTEXNORMALS];
@@ -777,6 +776,14 @@
==============================================================
*/
+
+enum{
+ THin = 1,
+ THsnd = 2,
+ THnet = 3
+};
+
+extern uint sys_frame_time;
void Sys_Init (void);
--- a/qcommon/qfiles.h
+++ b/qcommon/qfiles.h
@@ -33,6 +33,8 @@
#define IDPAKHEADER (('K'<<24)+('C'<<16)+('A'<<8)+'P')
+#pragma pack on
+
typedef struct
{
char name[56];
@@ -474,3 +476,5 @@
int numareaportals;
int firstareaportal;
} darea_t;
+
+#pragma pack off
--- a/ref/r_image.c
+++ b/ref/r_image.c
@@ -583,35 +583,23 @@
}
}
-
-
-/*
-===============
-R_InitImages
-===============
-*/
-void R_InitImages (void)
+void
+R_InitImages(void)
{
registration_sequence = 1;
}
-/*
-===============
-R_ShutdownImages
-===============
-*/
-void R_ShutdownImages (void)
+void
+R_ShutdownImages(void)
{
- int i;
- image_t *image;
+ int i;
+ image_t *image;
- for (i=0, image=r_images ; i<numr_images ; i++, image++)
- {
- if (!image->registration_sequence)
+ for(i=0, image=r_images; i<numr_images; i++, image++){
+ if(!image->registration_sequence)
continue; // free texture
// free it
- free (image->pixels[0]); // the other mip levels just follow
- memset (image, 0, sizeof(*image));
+ free(image->pixels[0]); // the other mip levels just follow
+ memset(image, 0, sizeof *image);
}
}
-
--- a/ref/r_local.h
+++ b/ref/r_local.h
@@ -774,10 +774,6 @@
extern cvar_t *r_lightlevel; //FIXME HACK
-extern cvar_t *vid_fullscreen;
-extern cvar_t *vid_gamma;
-
-
extern clipplane_t view_clipplanes[4];
extern int *pfrustum_indexes[4];
--- a/ref/r_main.c
+++ b/ref/r_main.c
@@ -241,38 +241,38 @@
void R_Register (void)
{
- sw_aliasstats = ri.Cvar_Get ("sw_polymodelstats", "0", 0);
- sw_allow_modex = ri.Cvar_Get( "sw_allow_modex", "1", CVAR_ARCHIVE );
- sw_clearcolor = ri.Cvar_Get ("sw_clearcolor", "2", 0);
- sw_drawflat = ri.Cvar_Get ("sw_drawflat", "0", 0);
- sw_draworder = ri.Cvar_Get ("sw_draworder", "0", 0);
- sw_maxedges = ri.Cvar_Get ("sw_maxedges", STRINGER(MAXSTACKSURFACES), 0);
- sw_maxsurfs = ri.Cvar_Get ("sw_maxsurfs", "0", 0);
- sw_mipcap = ri.Cvar_Get ("sw_mipcap", "0", 0);
- sw_mipscale = ri.Cvar_Get ("sw_mipscale", "1", 0);
- sw_reportedgeout = ri.Cvar_Get ("sw_reportedgeout", "0", 0);
- sw_reportsurfout = ri.Cvar_Get ("sw_reportsurfout", "0", 0);
- sw_stipplealpha = ri.Cvar_Get( "sw_stipplealpha", "0", CVAR_ARCHIVE );
- sw_surfcacheoverride = ri.Cvar_Get ("sw_surfcacheoverride", "0", 0);
- sw_waterwarp = ri.Cvar_Get ("sw_waterwarp", "1", 0);
- sw_mode = ri.Cvar_Get( "sw_mode", "0", CVAR_ARCHIVE );
+ sw_aliasstats = Cvar_Get("sw_polymodelstats", "0", 0);
+ sw_allow_modex = Cvar_Get("sw_allow_modex", "1", CVAR_ARCHIVE);
+ sw_clearcolor = Cvar_Get("sw_clearcolor", "2", 0);
+ sw_drawflat = Cvar_Get("sw_drawflat", "0", 0);
+ sw_draworder = Cvar_Get("sw_draworder", "0", 0);
+ sw_maxedges = Cvar_Get("sw_maxedges", STRINGER(MAXSTACKSURFACES), 0);
+ sw_maxsurfs = Cvar_Get("sw_maxsurfs", "0", 0);
+ sw_mipcap = Cvar_Get("sw_mipcap", "0", 0);
+ sw_mipscale = Cvar_Get("sw_mipscale", "1", 0);
+ sw_reportedgeout = Cvar_Get("sw_reportedgeout", "0", 0);
+ sw_reportsurfout = Cvar_Get("sw_reportsurfout", "0", 0);
+ sw_stipplealpha = Cvar_Get("sw_stipplealpha", "0", CVAR_ARCHIVE);
+ sw_surfcacheoverride = Cvar_Get("sw_surfcacheoverride", "0", 0);
+ sw_waterwarp = Cvar_Get ("sw_waterwarp", "1", 0);
+ sw_mode = Cvar_Get("sw_mode", "0", CVAR_ARCHIVE);
- r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
- r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
- r_fullbright = ri.Cvar_Get ("r_fullbright", "0", 0);
- r_drawentities = ri.Cvar_Get ("r_drawentities", "1", 0);
- r_drawworld = ri.Cvar_Get ("r_drawworld", "1", 0);
- r_dspeeds = ri.Cvar_Get ("r_dspeeds", "0", 0);
- r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
- r_lerpmodels = ri.Cvar_Get( "r_lerpmodels", "1", 0 );
- r_novis = ri.Cvar_Get( "r_novis", "0", 0 );
+ r_lefthand = Cvar_Get("hand", "0", CVAR_USERINFO | CVAR_ARCHIVE);
+ r_speeds = Cvar_Get("r_speeds", "0", 0);
+ r_fullbright = Cvar_Get("r_fullbright", "0", 0);
+ r_drawentities = Cvar_Get("r_drawentities", "1", 0);
+ r_drawworld = Cvar_Get("r_drawworld", "1", 0);
+ r_dspeeds = Cvar_Get("r_dspeeds", "0", 0);
+ r_lightlevel = Cvar_Get("r_lightlevel", "0", 0);
+ r_lerpmodels = Cvar_Get("r_lerpmodels", "1", 0);
+ r_novis = Cvar_Get("r_novis", "0", 0);
- vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
- vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
+ vid_fullscreen = Cvar_Get("vid_fullscreen", "0", CVAR_ARCHIVE);
+ vid_gamma = Cvar_Get("vid_gamma", "1", CVAR_ARCHIVE);
- ri.Cmd_AddCommand ("modellist", Mod_Modellist_f);
- ri.Cmd_AddCommand( "screenshot", R_ScreenShot_f );
- ri.Cmd_AddCommand( "imagelist", R_ImageList_f );
+ Cmd_AddCommand("modellist", Mod_Modellist_f);
+ Cmd_AddCommand("screenshot", R_ScreenShot_f);
+ Cmd_AddCommand("imagelist", R_ImageList_f);
sw_mode->modified = true; // force us to do mode specific stuff later
vid_gamma->modified = true; // force us to rebuild the gamma table later
@@ -282,11 +282,12 @@
//PGM
}
-void R_UnRegister (void)
+void
+R_UnRegister(void)
{
- ri.Cmd_RemoveCommand( "screenshot" );
- ri.Cmd_RemoveCommand ("modellist");
- ri.Cmd_RemoveCommand( "imagelist" );
+ Cmd_RemoveCommand("screenshot");
+ Cmd_RemoveCommand("modellist");
+ Cmd_RemoveCommand("imagelist");
}
/*
@@ -327,36 +328,25 @@
return true;
}
-/*
-===============
-R_Shutdown
-===============
-*/
-void R_Shutdown (void)
+void
+R_Shutdown(void)
{
- // free z buffer
- if (d_pzbuffer)
- {
- free (d_pzbuffer);
- d_pzbuffer = NULL;
+ if(d_pzbuffer){
+ free(d_pzbuffer);
+ d_pzbuffer = nil;
}
- // free surface cache
- if (sc_base)
- {
- D_FlushCaches ();
- free (sc_base);
- sc_base = NULL;
+ if(sc_base){
+ D_FlushCaches();
+ free(sc_base);
+ sc_base = nil;
}
-
- // free colormap
- if (vid.colormap)
- {
- free (vid.colormap);
- vid.colormap = NULL;
+ if(vid.colormap){
+ free(vid.colormap);
+ vid.colormap = nil;
}
- R_UnRegister ();
- Mod_FreeAll ();
- R_ShutdownImages ();
+ R_UnRegister();
+ Mod_FreeAll();
+ R_ShutdownImages();
SWimp_Shutdown();
}
--- a/ref/r_model.c
+++ b/ref/r_model.c
@@ -1210,32 +1210,20 @@
R_FreeUnusedImages ();
}
-
-//=============================================================================
-
-/*
-================
-Mod_Free
-================
-*/
-void Mod_Free (model_t *mod)
+void
+Mod_Free(model_t *mod)
{
- Hunk_Free (mod->extradata);
- memset (mod, 0, sizeof(*mod));
+ Hunk_Free(mod->extradata);
+ memset(mod, 0, sizeof *mod);
}
-/*
-================
-Mod_FreeAll
-================
-*/
-void Mod_FreeAll (void)
+void
+Mod_FreeAll(void)
{
- int i;
+ int i;
- for (i=0 ; i<mod_numknown ; i++)
- {
- if (mod_known[i].extradatasize)
- Mod_Free (&mod_known[i]);
+ for(i=0; i<mod_numknown; i++){
+ if(mod_known[i].extradatasize)
+ Mod_Free(&mod_known[i]);
}
}
--- a/server/sv_init.c
+++ b/server/sv_init.c
@@ -418,7 +418,7 @@
Cvar_Set ("nextserver", "");
//ZOID special hack for end game screen in coop mode
- if (Cvar_VariableValue ("coop") && !Q_strcasecmp(level, "victory.pcx"))
+ if (Cvar_VariableValue ("coop") && !cistrcmp(level, "victory.pcx"))
Cvar_Set ("nextserver", "gamemap \"*base1\"");
// if there is a $, use the remainder as a spawnpoint