18 Nov 2007
This commit is contained in:
parent
e39e2def92
commit
3954a9880c
|
@ -34,7 +34,13 @@ scroll = visible_offset
|
|||
|
||||
1. какие-то глюки отсечения визлифов (новый протокол глючит?)
|
||||
2. автокомплит для имен ресурсов OK
|
||||
3. переписать этот идиотский автокомплит, чтобы было красиво
|
||||
3. переписать этот идиотский автокомплит, чтобы было красиво OK
|
||||
4. Нормальные команды для проигрывания демок и видео OK
|
||||
5. Привести команды в порядок (162 штуки) OK
|
||||
6. избавиться от appactivate
|
||||
7. расширить мышиную функциональность
|
||||
8. Имплементировать сохранялки
|
||||
9. Избавиться от VID_GetModeInfo, VID_NewWindow, VID_AppActivate и VID_MenuInit
|
||||
|
||||
//==================================================
|
||||
// то, что уже готово
|
||||
|
|
|
@ -1109,7 +1109,6 @@ static void RoQShutdown( void )
|
|||
cinTable.fileName[0] = 0;
|
||||
|
||||
// let game known about movie state
|
||||
cl.attractloop = false;
|
||||
cls.state = ca_disconnected;
|
||||
Cbuf_AddText ("killserver\n");
|
||||
}
|
||||
|
|
|
@ -87,7 +87,7 @@ void CL_LevelShot_f( void )
|
|||
// check for exist
|
||||
sprintf( checkname, "graphics/background/%s.tga", cl.configstrings[CS_NAME] );
|
||||
if(!FS_FileExists( checkname )) re->ScrShot( checkname, true );
|
||||
|
||||
else Msg("levelshot for this map already created\nFirst remove old image if you wants do it again\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -227,11 +227,11 @@ void Con_Init (void)
|
|||
historyEditLines[i].widthInChars = g_console_field_width;
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f);
|
||||
Cmd_AddCommand ("togglechat", Con_ToggleChat_f);
|
||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f);
|
||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f);
|
||||
Cmd_AddCommand ("clear", Con_Clear_f);
|
||||
Cmd_AddCommand ("toggleconsole", Con_ToggleConsole_f, "opens or closes the console" );
|
||||
Cmd_AddCommand ("togglechat", Con_ToggleChat_f, "enable or disable chat mode" );
|
||||
Cmd_AddCommand ("messagemode", Con_MessageMode_f, "input a chat message to say to everyone" );
|
||||
Cmd_AddCommand ("messagemode2", Con_MessageMode2_f, "input a chat message to say to only your team" );
|
||||
Cmd_AddCommand ("clear", Con_Clear_f, "clear console history" );
|
||||
con.initialized = true;
|
||||
MsgDev(D_INFO, "Console initialized.\n");
|
||||
}
|
||||
|
|
|
@ -305,7 +305,8 @@ void CL_ParsePlayerstate (frame_t *oldframe, frame_t *newframe)
|
|||
if (flags & PS_M_GRAVITY) state->pmove.gravity = MSG_ReadShort (&net_message);
|
||||
if (flags & PS_M_DELTA_ANGLES) MSG_ReadPos32(&net_message, state->pmove.delta_angles );
|
||||
|
||||
if (cl.attractloop) state->pmove.pm_type = PM_FREEZE; // demo playback
|
||||
if(cls.state == ca_cinematic || cl.servercount > 0x10000)
|
||||
state->pmove.pm_type = PM_FREEZE; // demo or movie playback
|
||||
|
||||
// parse the rest of the player_state_t
|
||||
if (flags & PS_VIEWOFFSET)
|
||||
|
@ -489,7 +490,7 @@ void CL_ParseFrame (void)
|
|||
if (cl.frame.valid)
|
||||
{
|
||||
// getting a valid frame message ends the connection process
|
||||
if (cls.state != ca_active)
|
||||
if(cls.state != ca_active)
|
||||
{
|
||||
cls.state = ca_active;
|
||||
cl.force_refdef = true;
|
||||
|
|
|
@ -22,9 +22,301 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "client.h"
|
||||
|
||||
cvar_t *cl_nodelta;
|
||||
cvar_t *v_centermove;
|
||||
cvar_t *v_centerspeed;
|
||||
cvar_t *m_filter; // mouse sensetivity
|
||||
cvar_t *m_mouse;
|
||||
|
||||
unsigned frame_msec;
|
||||
unsigned old_sys_frame_time;
|
||||
bool in_appactive;
|
||||
|
||||
uint frame_msec;
|
||||
uint old_sys_frame_time;
|
||||
|
||||
int mouse_buttons;
|
||||
int mouse_oldbuttonstate;
|
||||
POINT current_pos;
|
||||
int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
|
||||
|
||||
bool mouseactive; // false when not focus app
|
||||
|
||||
bool restore_spi;
|
||||
bool mouseinitialized;
|
||||
int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
|
||||
bool mouseparmsvalid;
|
||||
|
||||
int window_center_x, window_center_y;
|
||||
RECT window_rect;
|
||||
|
||||
/*
|
||||
============================================================
|
||||
|
||||
MOUSE CONTROL
|
||||
|
||||
============================================================
|
||||
*/
|
||||
|
||||
// mouse variables
|
||||
|
||||
|
||||
bool mlooking;
|
||||
|
||||
void IN_MLookDown (void)
|
||||
{
|
||||
mlooking = true;
|
||||
}
|
||||
|
||||
void IN_MLookUp (void)
|
||||
{
|
||||
mlooking = false;
|
||||
if(!freelook->value && lookspring->value)
|
||||
IN_CenterView ();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_ActivateMouse
|
||||
|
||||
Called when the window gains focus or changes in some way
|
||||
===========
|
||||
*/
|
||||
void IN_ActivateMouse (void)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
if(!mouseinitialized) return;
|
||||
|
||||
if(!m_mouse->integer)
|
||||
{
|
||||
mouseactive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if(mouseactive) return;
|
||||
|
||||
mouseactive = true;
|
||||
|
||||
if( mouseparmsvalid ) restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
|
||||
|
||||
width = GetSystemMetrics(SM_CXSCREEN);
|
||||
height = GetSystemMetrics(SM_CYSCREEN);
|
||||
|
||||
GetWindowRect( host.hWnd, &window_rect);
|
||||
if (window_rect.left < 0) window_rect.left = 0;
|
||||
if (window_rect.top < 0) window_rect.top = 0;
|
||||
if (window_rect.right >= width) window_rect.right = width - 1;
|
||||
if (window_rect.bottom >= height-1) window_rect.bottom = height - 1;
|
||||
|
||||
window_center_x = (window_rect.right + window_rect.left)/2;
|
||||
window_center_y = (window_rect.top + window_rect.bottom)/2;
|
||||
SetCursorPos (window_center_x, window_center_y);
|
||||
|
||||
SetCapture( host.hWnd );
|
||||
ClipCursor(&window_rect);
|
||||
while( ShowCursor(false) >= 0 );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_DeactivateMouse
|
||||
|
||||
Called when the window loses focus
|
||||
===========
|
||||
*/
|
||||
void IN_DeactivateMouse (void)
|
||||
{
|
||||
if(!mouseinitialized || !mouseactive)
|
||||
return;
|
||||
|
||||
if( restore_spi ) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
|
||||
|
||||
mouseactive = false;
|
||||
|
||||
ClipCursor( NULL );
|
||||
ReleaseCapture();
|
||||
while( ShowCursor(true) < 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_StartupMouse
|
||||
===========
|
||||
*/
|
||||
void IN_StartupMouse (void)
|
||||
{
|
||||
cvar_t *cv;
|
||||
|
||||
cv = Cvar_Get ("in_initmouse", "1", CVAR_INIT);
|
||||
if ( !cv->value ) return;
|
||||
|
||||
mouseinitialized = true;
|
||||
mouseparmsvalid = SystemParametersInfo(SPI_GETMOUSE, 0, originalmouseparms, 0);
|
||||
mouse_buttons = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_MouseEvent
|
||||
===========
|
||||
*/
|
||||
void IN_MouseEvent (int mstate)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!mouseinitialized)
|
||||
return;
|
||||
|
||||
// perform button actions
|
||||
for (i=0 ; i<mouse_buttons ; i++)
|
||||
{
|
||||
if ( (mstate & (1<<i)) &&
|
||||
!(mouse_oldbuttonstate & (1<<i)) )
|
||||
{
|
||||
Key_Event (K_MOUSE1 + i, true, host.sv_timer);
|
||||
}
|
||||
|
||||
if ( !(mstate & (1<<i)) &&
|
||||
(mouse_oldbuttonstate & (1<<i)) )
|
||||
{
|
||||
Key_Event (K_MOUSE1 + i, false, host.sv_timer);
|
||||
}
|
||||
}
|
||||
|
||||
mouse_oldbuttonstate = mstate;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
CL_MouseMove
|
||||
===========
|
||||
*/
|
||||
void CL_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
if (!mouseactive)
|
||||
return;
|
||||
|
||||
// find mouse movement
|
||||
if (!GetCursorPos (¤t_pos))
|
||||
return;
|
||||
|
||||
mx = current_pos.x - window_center_x;
|
||||
my = current_pos.y - window_center_y;
|
||||
|
||||
#if 0
|
||||
if (!mx && !my)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && mlooking ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if ( (mlooking || freelook->value) && !(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
|
||||
// force the mouse to the center, so there's room to move
|
||||
if (mx || my) SetCursorPos (window_center_x, window_center_y);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========================================================================
|
||||
|
||||
VIEW CENTERING
|
||||
|
||||
=========================================================================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Activate
|
||||
|
||||
Called when the main window gains or loses focus.
|
||||
The window may have been destroyed and recreated
|
||||
between a deactivate and an activate.
|
||||
===========
|
||||
*/
|
||||
void IN_Activate (bool active)
|
||||
{
|
||||
in_appactive = active;
|
||||
mouseactive = !active; // force a new window check or turn off
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_UpdateMouse
|
||||
|
||||
Called every frame, even if not generating commands
|
||||
==================
|
||||
*/
|
||||
void CL_UpdateMouse( void )
|
||||
{
|
||||
if(!mouseinitialized) return;
|
||||
|
||||
if(!m_mouse || !in_appactive)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
return;
|
||||
}
|
||||
|
||||
if( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu )
|
||||
{
|
||||
// temporarily deactivate if in fullscreen
|
||||
if(!Cvar_VariableValue ("r_fullscreen"))
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
IN_ActivateMouse ();
|
||||
}
|
||||
|
||||
/*
|
||||
===================
|
||||
IN_ClearStates
|
||||
===================
|
||||
*/
|
||||
void IN_ClearStates (void)
|
||||
{
|
||||
mx_accum = 0;
|
||||
my_accum = 0;
|
||||
mouse_oldbuttonstate = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
@ -59,83 +351,72 @@ kbutton_t in_lookup, in_lookdown, in_moveleft, in_moveright;
|
|||
kbutton_t in_strafe, in_speed, in_use, in_attack;
|
||||
kbutton_t in_up, in_down;
|
||||
|
||||
int in_impulse;
|
||||
|
||||
int in_impulse;
|
||||
|
||||
void KeyDown (kbutton_t *b)
|
||||
{
|
||||
int k;
|
||||
int k;
|
||||
char *c;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
else
|
||||
k = -1; // typed manually at the console for continuous down
|
||||
if (c[0]) k = atoi(c);
|
||||
else k = -1; // typed manually at the console for continuous down
|
||||
|
||||
if (k == b->down[0] || k == b->down[1])
|
||||
return; // repeating key
|
||||
return; // repeating key
|
||||
|
||||
if (!b->down[0])
|
||||
b->down[0] = k;
|
||||
else if (!b->down[1])
|
||||
b->down[1] = k;
|
||||
if (!b->down[0]) b->down[0] = k;
|
||||
else if (!b->down[1]) b->down[1] = k;
|
||||
else
|
||||
{
|
||||
Msg ("Three keys down for a button!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (b->state & 1)
|
||||
return; // still down
|
||||
if (b->state & 1) return; // still down
|
||||
|
||||
// save timestamp
|
||||
c = Cmd_Argv(2);
|
||||
b->downtime = atoi(c);
|
||||
|
||||
if (!b->downtime) b->downtime = host.cl_timer - 100;
|
||||
|
||||
b->state |= 1 + 2; // down + impulse down
|
||||
}
|
||||
|
||||
void KeyUp (kbutton_t *b)
|
||||
{
|
||||
int k;
|
||||
int k;
|
||||
char *c;
|
||||
unsigned uptime;
|
||||
uint uptime;
|
||||
|
||||
c = Cmd_Argv(1);
|
||||
if (c[0])
|
||||
k = atoi(c);
|
||||
if (c[0]) k = atoi(c);
|
||||
else
|
||||
{ // typed manually at the console, assume for unsticking, so clear all
|
||||
{
|
||||
// typed manually at the console, assume for unsticking, so clear all
|
||||
b->down[0] = b->down[1] = 0;
|
||||
b->state = 4; // impulse up
|
||||
b->state = 4; // impulse up
|
||||
return;
|
||||
}
|
||||
|
||||
if (b->down[0] == k)
|
||||
b->down[0] = 0;
|
||||
else if (b->down[1] == k)
|
||||
b->down[1] = 0;
|
||||
else
|
||||
return; // key up without coresponding down (menu pass through)
|
||||
if (b->down[0] == k) b->down[0] = 0;
|
||||
else if (b->down[1] == k) b->down[1] = 0;
|
||||
else return; // key up without coresponding down (menu pass through)
|
||||
|
||||
if (b->down[0] || b->down[1])
|
||||
return; // some other key is still holding it down
|
||||
return; // some other key is still holding it down
|
||||
|
||||
if (!(b->state & 1))
|
||||
return; // still up (this should not happen)
|
||||
return; // still up (this should not happen)
|
||||
|
||||
// save timestamp
|
||||
c = Cmd_Argv(2);
|
||||
uptime = atoi(c);
|
||||
if (uptime)
|
||||
b->msec += uptime - b->downtime;
|
||||
else
|
||||
b->msec += 10;
|
||||
if (uptime) b->msec += uptime - b->downtime;
|
||||
else b->msec += 10;
|
||||
|
||||
b->state &= ~1; // now up
|
||||
b->state |= 4; // impulse up
|
||||
b->state &= ~1; // now up
|
||||
b->state |= 4; // impulse up
|
||||
}
|
||||
|
||||
void IN_KLookDown (void) {KeyDown(&in_klook);}
|
||||
|
@ -382,16 +663,14 @@ usercmd_t CL_CreateCmd (void)
|
|||
if (frame_msec > 200) frame_msec = 200;
|
||||
|
||||
// get basic movement from keyboard
|
||||
CL_BaseMove (&cmd);
|
||||
|
||||
// allow mice or other external controllers to add to the move
|
||||
IN_Move (&cmd);
|
||||
CL_BaseMove(&cmd);
|
||||
CL_MouseMove(&cmd);
|
||||
|
||||
CL_FinishMove (&cmd);
|
||||
|
||||
old_sys_frame_time = host.cl_timer;
|
||||
|
||||
//cmd.impulse = cls.framecount;
|
||||
//cmd.impulse = cls.framecount;
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
@ -409,44 +688,64 @@ CL_InitInput
|
|||
*/
|
||||
void CL_InitInput (void)
|
||||
{
|
||||
Cmd_AddCommand ("centerview",IN_CenterView);
|
||||
|
||||
Cmd_AddCommand ("+moveup",IN_UpDown);
|
||||
Cmd_AddCommand ("-moveup",IN_UpUp);
|
||||
Cmd_AddCommand ("+movedown",IN_DownDown);
|
||||
Cmd_AddCommand ("-movedown",IN_DownUp);
|
||||
Cmd_AddCommand ("+left",IN_LeftDown);
|
||||
Cmd_AddCommand ("-left",IN_LeftUp);
|
||||
Cmd_AddCommand ("+right",IN_RightDown);
|
||||
Cmd_AddCommand ("-right",IN_RightUp);
|
||||
Cmd_AddCommand ("+forward",IN_ForwardDown);
|
||||
Cmd_AddCommand ("-forward",IN_ForwardUp);
|
||||
Cmd_AddCommand ("+back",IN_BackDown);
|
||||
Cmd_AddCommand ("-back",IN_BackUp);
|
||||
Cmd_AddCommand ("+lookup", IN_LookupDown);
|
||||
Cmd_AddCommand ("-lookup", IN_LookupUp);
|
||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown);
|
||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp);
|
||||
Cmd_AddCommand ("+strafe", IN_StrafeDown);
|
||||
Cmd_AddCommand ("-strafe", IN_StrafeUp);
|
||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown);
|
||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp);
|
||||
Cmd_AddCommand ("+moveright", IN_MoverightDown);
|
||||
Cmd_AddCommand ("-moveright", IN_MoverightUp);
|
||||
Cmd_AddCommand ("+speed", IN_SpeedDown);
|
||||
Cmd_AddCommand ("-speed", IN_SpeedUp);
|
||||
Cmd_AddCommand ("+attack", IN_AttackDown);
|
||||
Cmd_AddCommand ("-attack", IN_AttackUp);
|
||||
Cmd_AddCommand ("+use", IN_UseDown);
|
||||
Cmd_AddCommand ("-use", IN_UseUp);
|
||||
Cmd_AddCommand ("impulse", IN_Impulse);
|
||||
Cmd_AddCommand ("+klook", IN_KLookDown);
|
||||
Cmd_AddCommand ("-klook", IN_KLookUp);
|
||||
// mouse variables
|
||||
m_filter = Cvar_Get("m_filter", "0", 0);
|
||||
m_mouse = Cvar_Get("mouse", "1", CVAR_ARCHIVE);
|
||||
|
||||
// centering
|
||||
v_centermove = Cvar_Get ("v_centermove", "0.15", 0);
|
||||
v_centerspeed = Cvar_Get ("v_centerspeed", "500", 0);
|
||||
cl_nodelta = Cvar_Get ("cl_nodelta", "0", 0);
|
||||
|
||||
Cmd_AddCommand ("centerview", IN_CenterView, "gradually recenter view (stop looking up/down)" );
|
||||
|
||||
// input commands
|
||||
Cmd_AddCommand ("+moveup",IN_UpDown, "swim upward");
|
||||
Cmd_AddCommand ("-moveup",IN_UpUp, "stop swimming upward");
|
||||
Cmd_AddCommand ("+movedown",IN_DownDown, "swim downward");
|
||||
Cmd_AddCommand ("-movedown",IN_DownUp, "stop swimming downward");
|
||||
Cmd_AddCommand ("+left",IN_LeftDown, "turn left");
|
||||
Cmd_AddCommand ("-left",IN_LeftUp, "stop turning left");
|
||||
Cmd_AddCommand ("+right",IN_RightDown, "turn right");
|
||||
Cmd_AddCommand ("-right",IN_RightUp, "stop turning right");
|
||||
Cmd_AddCommand ("+forward",IN_ForwardDown, "move forward");
|
||||
Cmd_AddCommand ("-forward",IN_ForwardUp, "stop moving forward");
|
||||
Cmd_AddCommand ("+back",IN_BackDown, "move backward");
|
||||
Cmd_AddCommand ("-back",IN_BackUp, "stop moving backward");
|
||||
Cmd_AddCommand ("+lookup", IN_LookupDown, "look upward");
|
||||
Cmd_AddCommand ("-lookup", IN_LookupUp, "stop looking upward");
|
||||
Cmd_AddCommand ("+lookdown", IN_LookdownDown, "look downward");
|
||||
Cmd_AddCommand ("-lookdown", IN_LookdownUp, "stop looking downward");
|
||||
Cmd_AddCommand ("+strafe", IN_StrafeDown, "activate strafing mode (move instead of turn)\n");
|
||||
Cmd_AddCommand ("-strafe", IN_StrafeUp, "deactivate strafing mode");
|
||||
Cmd_AddCommand ("+moveleft", IN_MoveleftDown, "strafe left");
|
||||
Cmd_AddCommand ("-moveleft", IN_MoveleftUp, "stop strafing left");
|
||||
Cmd_AddCommand ("+moveright", IN_MoverightDown, "strafe right");
|
||||
Cmd_AddCommand ("-moveright", IN_MoverightUp, "stop strafing right");
|
||||
Cmd_AddCommand ("+speed", IN_SpeedDown, "activate run mode (faster movement and turning)");
|
||||
Cmd_AddCommand ("-speed", IN_SpeedUp, "deactivate run mode");
|
||||
Cmd_AddCommand ("+attack", IN_AttackDown, "begin firing");
|
||||
Cmd_AddCommand ("-attack", IN_AttackUp, "stop firing");
|
||||
Cmd_AddCommand ("+use", IN_UseDown, "use item (doors, monsters, inventory, etc" );
|
||||
Cmd_AddCommand ("-use", IN_UseUp, "stop using item" );
|
||||
Cmd_AddCommand ("impulse", IN_Impulse, "send an impulse number to server (select weapon, use item, etc)");
|
||||
Cmd_AddCommand ("+klook", IN_KLookDown, "activate keyboard looking mode, do not recenter view");
|
||||
Cmd_AddCommand ("-klook", IN_KLookUp, "deactivate keyboard looking mode");
|
||||
Cmd_AddCommand ("+mlook", IN_MLookDown, "activate mouse looking mode, do not recenter view" );
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp, "deactivate mouse looking mode" );
|
||||
|
||||
IN_StartupMouse(); // init mouse
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
============
|
||||
CL_ShutdownInput
|
||||
============
|
||||
*/
|
||||
void CL_ShutdownInput( void )
|
||||
{
|
||||
IN_DeactivateMouse();
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
|
@ -455,12 +754,12 @@ CL_SendCmd
|
|||
*/
|
||||
void CL_SendCmd (void)
|
||||
{
|
||||
sizebuf_t buf;
|
||||
sizebuf_t buf;
|
||||
byte data[128];
|
||||
int i;
|
||||
usercmd_t *cmd, *oldcmd;
|
||||
usercmd_t nullcmd;
|
||||
int checksumIndex;
|
||||
int i;
|
||||
usercmd_t *cmd, *oldcmd;
|
||||
usercmd_t nullcmd;
|
||||
int checksumIndex;
|
||||
|
||||
// build a command even if not connected
|
||||
|
||||
|
@ -475,10 +774,14 @@ void CL_SendCmd (void)
|
|||
|
||||
SZ_Init (&buf, data, sizeof(data));
|
||||
|
||||
if (cls.state == ca_disconnected || cls.state == ca_connecting)
|
||||
if(cls.state == ca_disconnected || cls.state == ca_connecting)
|
||||
return;
|
||||
|
||||
if ( cls.state == ca_connected)
|
||||
// ignore commands for demo mode
|
||||
if(cls.state == ca_cinematic || cl.servercount > 0x10000)
|
||||
return;
|
||||
|
||||
if( cls.state == ca_connected)
|
||||
{
|
||||
if (cls.netchan.message.cursize || host.realtime - cls.netchan.last_sent > 1.0f )
|
||||
Netchan_Transmit (&cls.netchan, 0, buf.data);
|
||||
|
@ -494,12 +797,6 @@ void CL_SendCmd (void)
|
|||
MSG_WriteString (&cls.netchan.message, Cvar_Userinfo() );
|
||||
}
|
||||
|
||||
if (cmd->buttons && cls.state == ca_cinematic && !cl.attractloop)
|
||||
{
|
||||
// skip the rest of the cinematic
|
||||
SCR_FinishCinematic ();
|
||||
}
|
||||
|
||||
// begin a client move command
|
||||
MSG_WriteByte (&buf, clc_move);
|
||||
|
||||
|
|
|
@ -208,8 +208,6 @@ perform Tab expansion
|
|||
void Field_CompleteCommand( field_t *field )
|
||||
{
|
||||
field_t temp;
|
||||
const char *cmdname;
|
||||
char command[MAX_QPATH];
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
completionField = field;
|
||||
|
@ -232,27 +230,34 @@ void Field_CompleteCommand( field_t *field )
|
|||
if ( matchCount == 0 ) return; // no matches
|
||||
Mem_Copy(&temp, completionField, sizeof(field_t));
|
||||
|
||||
cmdname = completionField->buffer;
|
||||
if(Cmd_Argc() == 2)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
// autocomplete second arg
|
||||
if(!stricmp(Cmd_Argv(0), "map" ) || !stricmp(Cmd_Argv(0), "\\map" ))
|
||||
{
|
||||
if(Cmd_GetMapList(Cmd_Argv(1), filename, MAX_QPATH ))
|
||||
{
|
||||
sprintf( completionField->buffer, "%s %s", Cmd_Argv(0), filename );
|
||||
completionField->cursor = strlen( completionField->buffer );
|
||||
}
|
||||
result = Cmd_GetMapList(Cmd_Argv(1), filename, MAX_QPATH );
|
||||
}
|
||||
else if(!stricmp(Cmd_Argv(0), "demomap" ) || !stricmp(Cmd_Argv(0), "\\demomap" ))
|
||||
else if(!stricmp(Cmd_Argv(0), "demo" ) || !stricmp(Cmd_Argv(0), "\\demo" ))
|
||||
{
|
||||
if(Cmd_GetDemoList(Cmd_Argv(1), filename, MAX_QPATH ))
|
||||
{
|
||||
sprintf( completionField->buffer, "%s %s", Cmd_Argv(0), filename );
|
||||
completionField->cursor = strlen( completionField->buffer );
|
||||
}
|
||||
}
|
||||
return;
|
||||
result = Cmd_GetDemoList(Cmd_Argv(1), filename, MAX_QPATH );
|
||||
}
|
||||
else if(!stricmp(Cmd_Argv(0), "movie" ) || !stricmp(Cmd_Argv(0), "\\movie" ))
|
||||
{
|
||||
result = Cmd_GetMovieList(Cmd_Argv(1), filename, MAX_QPATH );
|
||||
}
|
||||
else if(!stricmp(Cmd_Argv(0), "changelevel" ) || !stricmp(Cmd_Argv(0), "\\changelevel" ))
|
||||
{
|
||||
result = Cmd_GetMapList(Cmd_Argv(1), filename, MAX_QPATH );
|
||||
}
|
||||
|
||||
if( result )
|
||||
{
|
||||
sprintf( completionField->buffer, "%s %s", Cmd_Argv(0), filename );
|
||||
completionField->cursor = strlen( completionField->buffer );
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if( matchCount == 1 )
|
||||
|
@ -1008,10 +1013,10 @@ Key_Init
|
|||
void Key_Init (void)
|
||||
{
|
||||
// register our functions
|
||||
Cmd_AddCommand ("bind",Key_Bind_f);
|
||||
Cmd_AddCommand ("unbind",Key_Unbind_f);
|
||||
Cmd_AddCommand ("unbindall",Key_Unbindall_f);
|
||||
Cmd_AddCommand ("bindlist",Key_Bindlist_f);
|
||||
Cmd_AddCommand ("bind", Key_Bind_f, "binds a command to the specified key in bindmap" );
|
||||
Cmd_AddCommand ("unbind", Key_Unbind_f, "removes a command on the specified key in bindmap" );
|
||||
Cmd_AddCommand ("unbindall", Key_Unbindall_f, "removes all commands from all keys in bindmap" );
|
||||
Cmd_AddCommand ("bindlist", Key_Bindlist_f, "display current key bindings" );
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -97,7 +97,6 @@ extern cvar_t *allow_download_players;
|
|||
extern cvar_t *allow_download_models;
|
||||
extern cvar_t *allow_download_sounds;
|
||||
extern cvar_t *allow_download_maps;
|
||||
extern HWND cl_hwnd;
|
||||
//======================================================================
|
||||
|
||||
|
||||
|
@ -137,7 +136,7 @@ void CL_Stop_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
// finish up
|
||||
// finish up
|
||||
len = -1;
|
||||
FS_Write (cls.demofile, &len, 4 );
|
||||
FS_Close (cls.demofile);
|
||||
|
@ -184,7 +183,7 @@ void CL_Record_f (void)
|
|||
}
|
||||
|
||||
// open the demo file
|
||||
sprintf (name, "demos/%s.dm2", Cmd_Argv(1));
|
||||
sprintf (name, "demos/%s.dem", Cmd_Argv(1));
|
||||
|
||||
Msg ("recording to %s.\n", name);
|
||||
cls.demofile = FS_Open (name, "wb");
|
||||
|
@ -207,10 +206,7 @@ void CL_Record_f (void)
|
|||
MSG_WriteByte (&buf, svc_serverdata);
|
||||
MSG_WriteLong (&buf, PROTOCOL_VERSION);
|
||||
MSG_WriteLong (&buf, 0x10000 + cl.servercount);
|
||||
MSG_WriteByte (&buf, 1); // demos are always attract loops
|
||||
MSG_WriteString (&buf, cl.gamedir);
|
||||
MSG_WriteShort (&buf, cl.playernum);
|
||||
|
||||
MSG_WriteString (&buf, cl.configstrings[CS_NAME]);
|
||||
|
||||
// configstrings
|
||||
|
@ -296,42 +292,6 @@ void Cmd_ForwardToServer (void)
|
|||
}
|
||||
}
|
||||
|
||||
void CL_Setenv_f( void )
|
||||
{
|
||||
int argc = Cmd_Argc();
|
||||
|
||||
if ( argc > 2 )
|
||||
{
|
||||
char buffer[1000];
|
||||
int i;
|
||||
|
||||
strcpy( buffer, Cmd_Argv(1) );
|
||||
strcat( buffer, "=" );
|
||||
|
||||
for ( i = 2; i < argc; i++ )
|
||||
{
|
||||
strcat( buffer, Cmd_Argv( i ) );
|
||||
strcat( buffer, " " );
|
||||
}
|
||||
|
||||
putenv( buffer );
|
||||
}
|
||||
else if ( argc == 2 )
|
||||
{
|
||||
char *env = getenv( Cmd_Argv(1) );
|
||||
|
||||
if ( env )
|
||||
{
|
||||
Msg( "%s=%s\n", Cmd_Argv(1), env );
|
||||
}
|
||||
else
|
||||
{
|
||||
Msg( "%s undefined\n", Cmd_Argv(1), env );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
CL_ForwardToServer_f
|
||||
|
@ -832,30 +792,6 @@ void CL_PingServers_f (void)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_Skins_f
|
||||
|
||||
Load or download any custom player skins and models
|
||||
=================
|
||||
*/
|
||||
void CL_Skins_f (void)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i=0 ; i<MAX_CLIENTS ; i++)
|
||||
{
|
||||
if (!cl.configstrings[CS_PLAYERSKINS+i][0])
|
||||
continue;
|
||||
Msg ("client %i: %s\n", i, cl.configstrings[CS_PLAYERSKINS+i]);
|
||||
SCR_UpdateScreen ();
|
||||
Sys_SendKeyEvents (); // pump message loop
|
||||
CL_ParseClientinfo (i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
CL_ConnectionlessPacket
|
||||
|
@ -904,16 +840,16 @@ void CL_ConnectionlessPacket (void)
|
|||
// remote command from gui front end
|
||||
if (!strcmp(c, "cmd"))
|
||||
{
|
||||
if (!NET_IsLocalAddress(net_from))
|
||||
if(!NET_IsLocalAddress(net_from))
|
||||
{
|
||||
Msg ("Command packet from remote host. Ignored.\n");
|
||||
return;
|
||||
}
|
||||
ShowWindow ( cl_hwnd, SW_RESTORE);
|
||||
SetForegroundWindow ( cl_hwnd );
|
||||
ShowWindow( host.hWnd, SW_RESTORE);
|
||||
SetForegroundWindow ( host.hWnd );
|
||||
s = MSG_ReadString (&net_message);
|
||||
Cbuf_AddText (s);
|
||||
Cbuf_AddText ("\n");
|
||||
Cbuf_AddText(s);
|
||||
Cbuf_AddText("\n");
|
||||
return;
|
||||
}
|
||||
// print command from somewhere
|
||||
|
@ -1341,14 +1277,14 @@ before allowing the client into the server
|
|||
*/
|
||||
void CL_Precache_f (void)
|
||||
{
|
||||
//Yet another hack to let old demos work
|
||||
//the old precache sequence
|
||||
if (Cmd_Argc() < 2) {
|
||||
unsigned map_checksum; // for detecting cheater maps
|
||||
|
||||
CM_LoadMap (cl.configstrings[CS_MODELS+1], true, &map_checksum);
|
||||
CL_RegisterSounds ();
|
||||
CL_PrepRefresh ();
|
||||
// Yet another hack to let old demos work
|
||||
// the old precache sequence
|
||||
if(Cmd_Argc() < 2)
|
||||
{
|
||||
uint map_checksum; // for detecting cheater maps
|
||||
CM_LoadMap(cl.configstrings[CS_MODELS+1], true, &map_checksum );
|
||||
CL_RegisterSounds();
|
||||
CL_PrepRefresh();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1370,7 +1306,7 @@ void CL_InitLocal (void)
|
|||
{
|
||||
cls.state = ca_disconnected;
|
||||
cls.realtime = 1.0f;
|
||||
CL_InitInput ();
|
||||
CL_InitInput();
|
||||
|
||||
adr0 = Cvar_Get( "adr0", "", CVAR_ARCHIVE );
|
||||
adr1 = Cvar_Get( "adr1", "", CVAR_ARCHIVE );
|
||||
|
@ -1439,43 +1375,37 @@ void CL_InitLocal (void)
|
|||
gender = Cvar_Get ("gender", "male", CVAR_USERINFO | CVAR_ARCHIVE);
|
||||
gender_auto = Cvar_Get ("gender_auto", "1", CVAR_ARCHIVE);
|
||||
gender->modified = false; // clear this so we know when user sets it manually
|
||||
|
||||
cl_vwep = Cvar_Get ("cl_vwep", "1", CVAR_ARCHIVE);
|
||||
|
||||
|
||||
//
|
||||
// register our commands
|
||||
//
|
||||
Cmd_AddCommand ("cmd", CL_ForwardToServer_f);
|
||||
Cmd_AddCommand ("pause", CL_Pause_f);
|
||||
Cmd_AddCommand ("pingservers", CL_PingServers_f);
|
||||
Cmd_AddCommand ("skins", CL_Skins_f);
|
||||
Cmd_AddCommand ("cmd", CL_ForwardToServer_f, "send a console commandline to the server" );
|
||||
Cmd_AddCommand ("pause", CL_Pause_f, "pause the game (if the server allows pausing)" );
|
||||
Cmd_AddCommand ("pingservers", CL_PingServers_f, "send a broadcast packet" );
|
||||
|
||||
Cmd_AddCommand ("userinfo", CL_Userinfo_f);
|
||||
Cmd_AddCommand ("snd_restart", CL_Snd_Restart_f);
|
||||
Cmd_AddCommand ("userinfo", CL_Userinfo_f, "print current client userinfo" );
|
||||
Cmd_AddCommand ("snd_restart", CL_Snd_Restart_f, "restart sound system" );
|
||||
|
||||
Cmd_AddCommand ("changing", CL_Changing_f);
|
||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f);
|
||||
Cmd_AddCommand ("record", CL_Record_f);
|
||||
Cmd_AddCommand ("stop", CL_Stop_f);
|
||||
Cmd_AddCommand ("changing", CL_Changing_f, "sent by server to tell client to wait for level change" );
|
||||
Cmd_AddCommand ("disconnect", CL_Disconnect_f, "disconnect from server" );
|
||||
Cmd_AddCommand ("record", CL_Record_f, "record a demo" );
|
||||
Cmd_AddCommand ("stop", CL_Stop_f, "stop recording a demo" );
|
||||
|
||||
Cmd_AddCommand ("quit", CL_Quit_f);
|
||||
Cmd_AddCommand ("quit", CL_Quit_f, "quit from game" );
|
||||
Cmd_AddCommand ("exit", CL_Quit_f, "quit from game" );
|
||||
|
||||
Cmd_AddCommand ("screenshot", CL_ScreenShot_f);
|
||||
Cmd_AddCommand ("levelshot", CL_LevelShot_f);
|
||||
Cmd_AddCommand ("screenshot", CL_ScreenShot_f, "takes a screenshot of the next rendered frame" );
|
||||
Cmd_AddCommand ("levelshot", CL_LevelShot_f, "same as \"screenshot\", used for create plaque images" );
|
||||
|
||||
Cmd_AddCommand ("connect", CL_Connect_f);
|
||||
Cmd_AddCommand ("reconnect", CL_Reconnect_f);
|
||||
Cmd_AddCommand ("connect", CL_Connect_f, "connect to a server by hostname" );
|
||||
Cmd_AddCommand ("reconnect", CL_Reconnect_f, "reconnect to current level" );
|
||||
|
||||
Cmd_AddCommand ("rcon", CL_Rcon_f);
|
||||
Cmd_AddCommand ("rcon", CL_Rcon_f, "sends a command to the server console (rcon_password and rcon_address required)" );
|
||||
|
||||
// Cmd_AddCommand ("packet", CL_Packet_f); // this is dangerous to leave in
|
||||
// this is dangerous to leave in
|
||||
// Cmd_AddCommand ("packet", CL_Packet_f, "send a packet with custom contents" );
|
||||
|
||||
Cmd_AddCommand ("setenv", CL_Setenv_f );
|
||||
|
||||
Cmd_AddCommand ("precache", CL_Precache_f);
|
||||
|
||||
Cmd_AddCommand ("download", CL_Download_f);
|
||||
Cmd_AddCommand ("precache", CL_Precache_f, "precache specified resource (by index)" );
|
||||
Cmd_AddCommand ("download", CL_Download_f, "download specified resource (by name)" );
|
||||
|
||||
//
|
||||
// forward to server commands
|
||||
|
@ -1483,25 +1413,25 @@ void CL_InitLocal (void)
|
|||
// the only thing this does is allow command completion
|
||||
// to work -- all unknown commands are automatically
|
||||
// forwarded to the server
|
||||
Cmd_AddCommand ("wave", NULL);
|
||||
Cmd_AddCommand ("inven", NULL);
|
||||
Cmd_AddCommand ("kill", NULL);
|
||||
Cmd_AddCommand ("use", NULL);
|
||||
Cmd_AddCommand ("drop", NULL);
|
||||
Cmd_AddCommand ("say", NULL);
|
||||
Cmd_AddCommand ("say_team", NULL);
|
||||
Cmd_AddCommand ("info", NULL);
|
||||
Cmd_AddCommand ("prog", NULL);
|
||||
Cmd_AddCommand ("give", NULL);
|
||||
Cmd_AddCommand ("god", NULL);
|
||||
Cmd_AddCommand ("notarget", NULL);
|
||||
Cmd_AddCommand ("noclip", NULL);
|
||||
Cmd_AddCommand ("invuse", NULL);
|
||||
Cmd_AddCommand ("invprev", NULL);
|
||||
Cmd_AddCommand ("invnext", NULL);
|
||||
Cmd_AddCommand ("invdrop", NULL);
|
||||
Cmd_AddCommand ("weapnext", NULL);
|
||||
Cmd_AddCommand ("weapprev", NULL);
|
||||
Cmd_AddCommand ("wave", NULL, NULL );
|
||||
Cmd_AddCommand ("inven", NULL, NULL );
|
||||
Cmd_AddCommand ("kill", NULL, NULL );
|
||||
Cmd_AddCommand ("use", NULL, NULL );
|
||||
Cmd_AddCommand ("drop", NULL, NULL );
|
||||
Cmd_AddCommand ("say", NULL, NULL );
|
||||
Cmd_AddCommand ("say_team", NULL, NULL );
|
||||
Cmd_AddCommand ("info", NULL, NULL );
|
||||
Cmd_AddCommand ("prog", NULL, NULL );
|
||||
Cmd_AddCommand ("give", NULL, NULL );
|
||||
Cmd_AddCommand ("god", NULL, NULL );
|
||||
Cmd_AddCommand ("notarget", NULL, NULL );
|
||||
Cmd_AddCommand ("noclip", NULL, NULL );
|
||||
Cmd_AddCommand ("invuse", NULL, NULL );
|
||||
Cmd_AddCommand ("invprev", NULL, NULL );
|
||||
Cmd_AddCommand ("invnext", NULL, NULL );
|
||||
Cmd_AddCommand ("invdrop", NULL, NULL );
|
||||
Cmd_AddCommand ("weapnext", NULL, NULL );
|
||||
Cmd_AddCommand ("weapprev", NULL, NULL );
|
||||
}
|
||||
|
||||
|
||||
|
@ -1638,7 +1568,7 @@ CL_Frame
|
|||
|
||||
==================
|
||||
*/
|
||||
void CL_Frame (float time)
|
||||
void CL_Frame( float time )
|
||||
{
|
||||
static float extratime;
|
||||
static float lasttimecalled;
|
||||
|
@ -1656,7 +1586,7 @@ void CL_Frame (float time)
|
|||
}
|
||||
|
||||
// let the mouse activate or deactivate
|
||||
IN_Frame ();
|
||||
CL_UpdateMouse();
|
||||
|
||||
// decide the simulation time
|
||||
cls.frametime = extratime;
|
||||
|
@ -1668,18 +1598,17 @@ void CL_Frame (float time)
|
|||
if (time > 5.0f) cls.netchan.last_received = host.realtime;
|
||||
|
||||
// fetch results from server
|
||||
CL_ReadPackets ();
|
||||
CL_ReadPackets();
|
||||
|
||||
// send a new command message to the server
|
||||
CL_SendCommand ();
|
||||
CL_SendCommand();
|
||||
|
||||
// predict all unacknowledged movements
|
||||
CL_PredictMovement ();
|
||||
|
||||
// allow rendering DLL change
|
||||
VID_CheckChanges ();
|
||||
if (!cl.refresh_prepped && cls.state == ca_active)
|
||||
CL_PrepRefresh ();
|
||||
if(!cl.refresh_prepped && cls.state == ca_active)
|
||||
CL_PrepRefresh();
|
||||
|
||||
// update the screen
|
||||
SCR_UpdateScreen ();
|
||||
|
@ -1708,15 +1637,14 @@ CL_Init
|
|||
*/
|
||||
void CL_Init (void)
|
||||
{
|
||||
if (dedicated->value)
|
||||
return; // nothing running on the client
|
||||
if (dedicated->value) return; // nothing running on the client
|
||||
|
||||
// all archived variables will now be loaded
|
||||
scr_loading = _Cvar_Get("scr_loading", "0", 0, "progress bar loading value" );
|
||||
|
||||
Con_Init ();
|
||||
VID_Init ();
|
||||
V_Init ();
|
||||
Con_Init();
|
||||
VID_Init();
|
||||
V_Init();
|
||||
CG_Init();
|
||||
|
||||
net_message.data = net_message_buffer;
|
||||
|
@ -1726,10 +1654,6 @@ void CL_Init (void)
|
|||
|
||||
SCR_Init ();
|
||||
CL_InitLocal ();
|
||||
IN_Init ();
|
||||
|
||||
Cbuf_AddText ("exec autoexec.cfg\n");
|
||||
Cbuf_Execute ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1748,8 +1672,7 @@ void CL_Shutdown(void)
|
|||
|
||||
CL_WriteConfiguration ();
|
||||
S_Shutdown();
|
||||
IN_Shutdown ();
|
||||
VID_FreeRender();
|
||||
CL_ShutdownInput();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -290,10 +290,10 @@ CL_ParseServerData
|
|||
*/
|
||||
void CL_ParseServerData (void)
|
||||
{
|
||||
char *str;
|
||||
char *str;
|
||||
int i;
|
||||
|
||||
MsgDev (D_INFO, "Serverdata packet received.\n");
|
||||
MsgDev(D_INFO, "Serverdata packet received.\n");
|
||||
|
||||
// wipe the client_t struct
|
||||
CL_ClearState ();
|
||||
|
@ -306,11 +306,6 @@ void CL_ParseServerData (void)
|
|||
if (i != PROTOCOL_VERSION) Host_Error("Server returned version %i, not %i", i, PROTOCOL_VERSION);
|
||||
|
||||
cl.servercount = MSG_ReadLong (&net_message);
|
||||
cl.attractloop = MSG_ReadByte (&net_message);
|
||||
|
||||
// game directory
|
||||
str = MSG_ReadString (&net_message);
|
||||
strncpy (cl.gamedir, str, sizeof(cl.gamedir)-1);
|
||||
|
||||
// parse player entity number
|
||||
cl.playernum = MSG_ReadShort (&net_message);
|
||||
|
@ -629,10 +624,6 @@ void CL_ParseServerMessage (void)
|
|||
// other commands
|
||||
switch (cmd)
|
||||
{
|
||||
default:
|
||||
Host_Error("CL_ParseServerMessage: Illegible server message %d\n", cmd );
|
||||
break;
|
||||
|
||||
case svc_nop:
|
||||
// Msg ("svc_nop\n");
|
||||
break;
|
||||
|
@ -712,6 +703,9 @@ void CL_ParseServerMessage (void)
|
|||
case svc_deltapacketentities:
|
||||
Host_Error("Out of place frame data\n");
|
||||
break;
|
||||
default:
|
||||
Host_Error("CL_ParseServerMessage: Illegible server message %d\n", cmd );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -355,9 +355,9 @@ void SCR_Init (void)
|
|||
cl_levelshot_name = Cvar_Get("cl_levelshot_name", "common/black", 0 );
|
||||
|
||||
// register our commands
|
||||
Cmd_AddCommand ("timerefresh", SCR_TimeRefresh_f);
|
||||
Cmd_AddCommand ("loading", SCR_Loading_f);
|
||||
Cmd_AddCommand ("skyname", CL_SetSky_f );
|
||||
Cmd_AddCommand ("timerefresh", SCR_TimeRefresh_f, "turn quickly and print rendering statistcs" );
|
||||
Cmd_AddCommand ("loading", SCR_Loading_f, "prepare client to a loading new map" );
|
||||
Cmd_AddCommand ("skyname", CL_SetSky_f, "set new skybox by basename" );
|
||||
|
||||
scr_initialized = true;
|
||||
|
||||
|
|
|
@ -587,11 +587,11 @@ V_Init
|
|||
*/
|
||||
void V_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("gun_next", V_Gun_Next_f);
|
||||
Cmd_AddCommand ("gun_prev", V_Gun_Prev_f);
|
||||
Cmd_AddCommand ("gun_model", V_Gun_Model_f);
|
||||
Cmd_AddCommand ("gun_next", V_Gun_Next_f, "decrease viewmodel current frame" );
|
||||
Cmd_AddCommand ("gun_prev", V_Gun_Prev_f, "increase viewmodel current frame" );
|
||||
Cmd_AddCommand ("gun_model", V_Gun_Model_f, "change gun (not a weapon, just viewmodel)" );
|
||||
|
||||
Cmd_AddCommand ("viewpos", V_Viewpos_f);
|
||||
Cmd_AddCommand ("viewpos", V_Viewpos_f, "prints current player origin" );
|
||||
|
||||
crosshair = Cvar_Get ("crosshair", "0", CVAR_ARCHIVE);
|
||||
|
||||
|
|
|
@ -189,11 +189,8 @@ typedef struct
|
|||
//
|
||||
// server state information
|
||||
//
|
||||
bool attractloop; // running the attract loop, any key will menu
|
||||
int servercount; // server identification for prespawns
|
||||
char gamedir[MAX_QPATH];
|
||||
int servercount; // server identification for prespawns
|
||||
int playernum;
|
||||
|
||||
char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH];
|
||||
|
||||
//
|
||||
|
@ -220,7 +217,8 @@ of server connections
|
|||
==================================================================
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
typedef enum
|
||||
{
|
||||
ca_uninitialized,
|
||||
ca_disconnected, // not talking to a server
|
||||
ca_connecting, // sending request packets to the server
|
||||
|
@ -330,6 +328,7 @@ extern cvar_t *m_pitch;
|
|||
extern cvar_t *m_yaw;
|
||||
extern cvar_t *m_forward;
|
||||
extern cvar_t *m_side;
|
||||
extern cvar_t *m_mouse;
|
||||
|
||||
extern cvar_t *freelook;
|
||||
|
||||
|
@ -503,7 +502,9 @@ extern kbutton_t in_mlook, in_klook;
|
|||
extern kbutton_t in_strafe;
|
||||
extern kbutton_t in_speed;
|
||||
|
||||
void CL_InitInput (void);
|
||||
void CL_InitInput( void );
|
||||
void CL_ShutdownInput( void );
|
||||
void CL_UpdateMouse( void );
|
||||
void CL_SendCmd (void);
|
||||
void CL_SendMove (usercmd_t *cmd);
|
||||
|
||||
|
|
|
@ -147,7 +147,7 @@ void Cbuf_ExecuteText (int exec_when, const char *text)
|
|||
Cbuf_Execute
|
||||
============
|
||||
*/
|
||||
void Cbuf_Execute (void)
|
||||
void Cbuf_Execute( void )
|
||||
{
|
||||
int i;
|
||||
char *text;
|
||||
|
@ -272,14 +272,9 @@ bind g "cmd use rocket ; +attack ; wait ; -attack ; cmd use blaster"
|
|||
*/
|
||||
void Cmd_Wait_f (void)
|
||||
{
|
||||
if(Cmd_Argc() == 2)
|
||||
{
|
||||
cmd_wait = atoi( Cmd_Argv( 1 ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd_wait = 1;
|
||||
}
|
||||
if(Cmd_Argc() == 1) cmd_wait = 1;
|
||||
else cmd_wait = atoi(Cmd_Argv( 1 ));
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -342,7 +337,7 @@ bool Cmd_GetMapList (const char *s, char *completedname, int length )
|
|||
char message[MAX_QPATH];
|
||||
char matchbuf[MAX_QPATH];
|
||||
byte buf[MAX_SYSPATH]; // 1 kb
|
||||
int i;
|
||||
int i, nummaps;
|
||||
|
||||
t = FS_Search(va("maps/%s*.bsp", s), true );
|
||||
if( !t ) return false;
|
||||
|
@ -351,16 +346,17 @@ bool Cmd_GetMapList (const char *s, char *completedname, int length )
|
|||
strncpy( completedname, matchbuf, length );
|
||||
if(t->numfilenames == 1) return true;
|
||||
|
||||
Msg("^3 %i maps found :\n", t->numfilenames);
|
||||
|
||||
for(i = 0; i < t->numfilenames; i++)
|
||||
for(i = 0, nummaps = 0; i < t->numfilenames; i++)
|
||||
{
|
||||
const char *data = NULL;
|
||||
char *entities = NULL;
|
||||
char entfilename[MAX_QPATH];
|
||||
int ver = -1, lumpofs = 0, lumplen = 0;
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
strncpy(message, "No Title", sizeof(message));
|
||||
if( std.stricmp(ext, "bsp" )) continue;
|
||||
|
||||
strncpy(message, "^1error^7", sizeof(message));
|
||||
f = FS_Open(t->filenames[i], "rb" );
|
||||
|
||||
if( f )
|
||||
|
@ -369,12 +365,36 @@ bool Cmd_GetMapList (const char *s, char *completedname, int length )
|
|||
FS_Read(f, buf, 1024);
|
||||
if(!memcmp(buf, "IBSP", 4))
|
||||
{
|
||||
dheader_t *header = (dheader_t *)buf;
|
||||
ver = LittleLong(((int *)buf)[1]);
|
||||
if(ver == BSPMOD_VERSION)
|
||||
|
||||
switch(ver)
|
||||
{
|
||||
dheader_t *header = (dheader_t *)buf;
|
||||
case 38: // quake2 (xash)
|
||||
case 46: // quake3
|
||||
case 47: // return to castle wolfenstein
|
||||
lumpofs = LittleLong(header->lumps[LUMP_ENTITIES].fileofs);
|
||||
lumplen = LittleLong(header->lumps[LUMP_ENTITIES].filelen);
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lump_t ents; // quake1 entity lump
|
||||
memcpy(&ents, buf + 4, sizeof(lump_t)); // skip first four bytes (version)
|
||||
ver = LittleLong(((int *)buf)[0]);
|
||||
|
||||
switch( ver )
|
||||
{
|
||||
case 28: // quake 1 beta
|
||||
case 29: // quake 1 regular
|
||||
case 30: // Half-Life regular
|
||||
lumpofs = LittleLong(ents.fileofs);
|
||||
lumplen = LittleLong(ents.filelen);
|
||||
break;
|
||||
default:
|
||||
ver = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +430,8 @@ bool Cmd_GetMapList (const char *s, char *completedname, int length )
|
|||
{
|
||||
// get map version
|
||||
Com_ParseToken(&data);
|
||||
ver = atoi(com_token);
|
||||
// old xash maps are Half-Life, so don't overwrite version
|
||||
if(ver > 30) ver = atoi(com_token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -421,13 +442,19 @@ bool Cmd_GetMapList (const char *s, char *completedname, int length )
|
|||
|
||||
switch(ver)
|
||||
{
|
||||
case 38: strncpy((char *)buf, "Q2", sizeof(buf)); break;
|
||||
case 220: strncpy((char *)buf, "Xash", sizeof(buf)); break;
|
||||
case 28: strncpy((char *)buf, "Quake1 beta", sizeof(buf)); break;
|
||||
case 29: strncpy((char *)buf, "Quake1", sizeof(buf)); break;
|
||||
case 30: strncpy((char *)buf, "Half-Life", sizeof(buf)); break;
|
||||
case 38: strncpy((char *)buf, "Quake 2", sizeof(buf)); break;
|
||||
case 46: strncpy((char *)buf, "Quake 3", sizeof(buf)); break;
|
||||
case 47: strncpy((char *)buf, "RTCW", sizeof(buf)); break;
|
||||
case 220: strncpy((char *)buf, "Xash 3D", sizeof(buf)); break;
|
||||
default: strncpy((char *)buf, "??", sizeof(buf)); break;
|
||||
}
|
||||
Msg("%16s (%s) ^3%s^7\n", matchbuf, buf, message);
|
||||
nummaps++;
|
||||
}
|
||||
Msg("\n");
|
||||
Msg("\n^3 %i maps found.\n", nummaps );
|
||||
Z_Free( t );
|
||||
|
||||
// cut shortestMatch to the amount common with s
|
||||
|
@ -450,23 +477,70 @@ bool Cmd_GetDemoList (const char *s, char *completedname, int length )
|
|||
{
|
||||
search_t *t;
|
||||
char matchbuf[MAX_QPATH];
|
||||
int i;
|
||||
int i, numdems;
|
||||
|
||||
t = FS_Search(va("demos/%s*.dm2", s ), true);
|
||||
t = FS_Search(va("demos/%s*.dem", s ), true);
|
||||
if(!t) return false;
|
||||
|
||||
FS_FileBase(t->filenames[0], matchbuf );
|
||||
if(completedname && length) strncpy( completedname, matchbuf, length );
|
||||
if(t->numfilenames == 1) return true;
|
||||
|
||||
Msg("^3 %i demos found :\n", t->numfilenames);
|
||||
|
||||
for(i = 0; i < t->numfilenames; i++)
|
||||
for(i = 0, numdems = 0; i < t->numfilenames; i++)
|
||||
{
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( std.stricmp(ext, "dem" )) continue;
|
||||
FS_FileBase(t->filenames[i], matchbuf );
|
||||
Msg("%16s\n", matchbuf );
|
||||
numdems++;
|
||||
}
|
||||
Msg("\n");
|
||||
Msg("\n^3 %i demos found.\n", numdems );
|
||||
Z_Free(t);
|
||||
|
||||
// cut shortestMatch to the amount common with s
|
||||
if(completedname && length)
|
||||
{
|
||||
for( i = 0; matchbuf[i]; i++ )
|
||||
{
|
||||
if(tolower(completedname[i]) != tolower(matchbuf[i]))
|
||||
completedname[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
=====================================
|
||||
Cmd_GetMovieList
|
||||
|
||||
Prints or complete movie filename
|
||||
=====================================
|
||||
*/
|
||||
bool Cmd_GetMovieList (const char *s, char *completedname, int length )
|
||||
{
|
||||
search_t *t;
|
||||
char matchbuf[MAX_QPATH];
|
||||
int i, nummovies;
|
||||
|
||||
t = FS_Search(va("video/%s*.roq", s ), true);
|
||||
if(!t) return false;
|
||||
|
||||
FS_FileBase(t->filenames[0], matchbuf );
|
||||
if(completedname && length) strncpy( completedname, matchbuf, length );
|
||||
if(t->numfilenames == 1) return true;
|
||||
|
||||
for(i = 0, nummovies = 0; i < t->numfilenames; i++)
|
||||
{
|
||||
const char *ext = FS_FileExtension( t->filenames[i] );
|
||||
|
||||
if( std.stricmp(ext, "roq" )) continue;
|
||||
FS_FileBase(t->filenames[i], matchbuf );
|
||||
Msg("%16s\n", matchbuf );
|
||||
nummovies++;
|
||||
}
|
||||
Msg("\n^3 %i movies found.\n", nummovies );
|
||||
Z_Free(t);
|
||||
|
||||
// cut shortestMatch to the amount common with s
|
||||
|
@ -636,7 +710,7 @@ void Cmd_TokenizeString (const char *text_in)
|
|||
Cmd_AddCommand
|
||||
============
|
||||
*/
|
||||
void _Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *cmd_desc)
|
||||
void Cmd_AddCommand (const char *cmd_name, xcommand_t function, const char *cmd_desc)
|
||||
{
|
||||
cmd_function_t *cmd;
|
||||
|
||||
|
@ -792,11 +866,11 @@ void Cmd_Init( int argc, char **argv )
|
|||
Cbuf_Init( argc, argv );
|
||||
|
||||
// register our commands
|
||||
Cmd_AddCommand ("exec", Cmd_Exec_f);
|
||||
Cmd_AddCommand ("echo", Cmd_Echo_f);
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f);
|
||||
Cmd_AddCommand ("cmdlist", Cmd_List_f);
|
||||
Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f );
|
||||
Cmd_AddCommand ("exec", Cmd_Exec_f, "execute a script file" );
|
||||
Cmd_AddCommand ("echo", Cmd_Echo_f, "print a message to the console (useful in scripts)" );
|
||||
Cmd_AddCommand ("wait", Cmd_Wait_f, "make script execution wait for some rendered frames" );
|
||||
Cmd_AddCommand ("cmdlist", Cmd_List_f, "display all console commands beginning with the specified prefix" );
|
||||
Cmd_AddCommand ("stuffcmds", Cmd_StuffCmds_f, "execute commandline parameters (must be present in init.rc script)" );
|
||||
|
||||
// determine debug and developer mode
|
||||
if(FS_CheckParm ("-debug")) host.debug = true;
|
||||
|
|
|
@ -987,13 +987,13 @@ void Cvar_Init (void)
|
|||
{
|
||||
host_cheats = Cvar_Get("host_cheats", "1", CVAR_READ_ONLY | CVAR_SYSTEMINFO );
|
||||
|
||||
Cmd_AddCommand ("toggle", Cvar_Toggle_f);
|
||||
Cmd_AddCommand ("set", Cvar_Set_f);
|
||||
Cmd_AddCommand ("sets", Cvar_SetS_f);
|
||||
Cmd_AddCommand ("setu", Cvar_SetU_f);
|
||||
Cmd_AddCommand ("seta", Cvar_SetA_f);
|
||||
Cmd_AddCommand ("reset", Cvar_Reset_f);
|
||||
Cmd_AddCommand ("cvarlist", Cvar_List_f);
|
||||
Cmd_AddCommand ("cvar_restart", Cvar_Restart_f);
|
||||
Cmd_AddCommand ("toggle", Cvar_Toggle_f, "toggles a console variable's values (use for more info)" );
|
||||
Cmd_AddCommand ("set", Cvar_Set_f, "create or change the value of a console variable" );
|
||||
Cmd_AddCommand ("sets", Cvar_SetS_f, "create or change the value of a serverinfo variable");
|
||||
Cmd_AddCommand ("setu", Cvar_SetU_f, "create or change the value of a userinfo variable");
|
||||
Cmd_AddCommand ("seta", Cvar_SetA_f, "create or change the value of a console variable that will be saved to vars.rc");
|
||||
Cmd_AddCommand ("reset", Cvar_Reset_f, "reset any type variable to initial value" );
|
||||
Cmd_AddCommand ("cvarlist", Cvar_List_f, "display all console variables beginning with the specified prefix" );
|
||||
Cmd_AddCommand ("unsetall", Cvar_Restart_f, "reset all console variables to their default values" );
|
||||
|
||||
}
|
||||
|
|
|
@ -89,3 +89,17 @@ typedef enum
|
|||
|
||||
K_LAST_KEY // this had better be < 256!
|
||||
} keyNum_t;
|
||||
|
||||
static byte scan_to_key[128] =
|
||||
{
|
||||
0,27,'1','2','3','4','5','6','7','8','9','0','-','=',K_BACKSPACE,9,
|
||||
'q','w','e','r','t','y','u','i','o','p','[',']', 13 , K_CTRL,
|
||||
'a','s','d','f','g','h','j','k','l',';','\'','`',
|
||||
K_SHIFT,'\\','z','x','c','v','b','n','m',',','.','/',K_SHIFT,
|
||||
'*',K_ALT,' ',K_CAPSLOCK,
|
||||
K_F1,K_F2,K_F3,K_F4,K_F5,K_F6,K_F7,K_F8,K_F9,K_F10,
|
||||
K_PAUSE,0,K_HOME,K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,
|
||||
K_RIGHTARROW,K_KP_PLUS,K_END,K_DOWNARROW,K_PGDN,K_INS,K_DEL,
|
||||
0,0,0,K_F11,K_F12,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
|
||||
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0
|
||||
};
|
|
@ -3280,22 +3280,22 @@ M_Init
|
|||
*/
|
||||
void M_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("menu_main", M_Menu_Main_f);
|
||||
Cmd_AddCommand ("menu_game", M_Menu_Game_f);
|
||||
Cmd_AddCommand ("menu_loadgame", M_Menu_LoadGame_f);
|
||||
Cmd_AddCommand ("menu_savegame", M_Menu_SaveGame_f);
|
||||
Cmd_AddCommand ("menu_joinserver", M_Menu_JoinServer_f);
|
||||
Cmd_AddCommand ("menu_addressbook", M_Menu_AddressBook_f);
|
||||
Cmd_AddCommand ("menu_startserver", M_Menu_StartServer_f);
|
||||
Cmd_AddCommand ("menu_dmoptions", M_Menu_DMOptions_f);
|
||||
Cmd_AddCommand ("menu_playerconfig", M_Menu_PlayerConfig_f);
|
||||
Cmd_AddCommand ("menu_downloadoptions", M_Menu_DownloadOptions_f);
|
||||
Cmd_AddCommand ("menu_credits", M_Menu_Credits_f );
|
||||
Cmd_AddCommand ("menu_multiplayer", M_Menu_Multiplayer_f );
|
||||
Cmd_AddCommand ("menu_video", M_Menu_Video_f);
|
||||
Cmd_AddCommand ("menu_options", M_Menu_Options_f);
|
||||
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f);
|
||||
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f);
|
||||
Cmd_AddCommand ("menu_main", M_Menu_Main_f, "opens main menu" );
|
||||
Cmd_AddCommand ("menu_game", M_Menu_Game_f, "opens game menu" );
|
||||
Cmd_AddCommand ("menu_loadgame", M_Menu_LoadGame_f, "opens menu loadgame" );
|
||||
Cmd_AddCommand ("menu_savegame", M_Menu_SaveGame_f, "opens menu savegame" );
|
||||
Cmd_AddCommand ("menu_joinserver", M_Menu_JoinServer_f, "opens join server menu" );
|
||||
Cmd_AddCommand ("menu_addressbook", M_Menu_AddressBook_f, "opens address book menu" );
|
||||
Cmd_AddCommand ("menu_startserver", M_Menu_StartServer_f, "opens start server menu" );
|
||||
Cmd_AddCommand ("menu_dmoptions", M_Menu_DMOptions_f, "opens deathmath options menu" );
|
||||
Cmd_AddCommand ("menu_playerconfig", M_Menu_PlayerConfig_f, "opens player config menu" );
|
||||
Cmd_AddCommand ("menu_downloadoptions", M_Menu_DownloadOptions_f, "opens download menu" );
|
||||
Cmd_AddCommand ("menu_credits", M_Menu_Credits_f, "show credits" );
|
||||
Cmd_AddCommand ("menu_multiplayer", M_Menu_Multiplayer_f, "opens multiplayer menu" );
|
||||
Cmd_AddCommand ("menu_video", M_Menu_Video_f, "opens video options menu");
|
||||
Cmd_AddCommand ("menu_options", M_Menu_Options_f, "opens main options menu");
|
||||
Cmd_AddCommand ("menu_keys", M_Menu_Keys_f, "opens redefinition keys menu" );
|
||||
Cmd_AddCommand ("menu_quit", M_Menu_Quit_f, "show quit dialog" );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -522,11 +522,6 @@ void Netchan_OutOfBandPrint (int net_socket, netadr_t adr, char *format, ...);
|
|||
bool Netchan_Process (netchan_t *chan, sizebuf_t *msg);
|
||||
bool Netchan_CanReliable (netchan_t *chan);
|
||||
|
||||
void IN_Init( void );
|
||||
void IN_Shutdown( void );
|
||||
void IN_Commands( void ); // oportunity for devices to stick commands on the script buffer
|
||||
void IN_Frame( void );
|
||||
void IN_Move( usercmd_t *cmd ); // add additional movement on top of the keyboard move cmd
|
||||
void IN_Activate( bool active );
|
||||
void IN_MouseEvent( int mstate );
|
||||
|
||||
|
|
|
@ -1897,17 +1897,16 @@ PRVM_Init
|
|||
*/
|
||||
void PRVM_Init (void)
|
||||
{
|
||||
Cmd_AddCommand ("prvm_edict", PRVM_ED_PrintEdict_f);
|
||||
Cmd_AddCommand ("prvm_edicts", PRVM_ED_PrintEdicts_f);
|
||||
Cmd_AddCommand ("prvm_edictcount", PRVM_ED_Count_f);
|
||||
Cmd_AddCommand ("prvm_profile", PRVM_Profile_f);
|
||||
Cmd_AddCommand ("prvm_fields", PRVM_Fields_f);
|
||||
Cmd_AddCommand ("prvm_globals", PRVM_Globals_f);
|
||||
Cmd_AddCommand ("prvm_global", PRVM_Global_f);
|
||||
Cmd_AddCommand ("prvm_globalset", PRVM_GlobalSet_f);
|
||||
Cmd_AddCommand ("prvm_edictset", PRVM_ED_EdictSet_f);
|
||||
Cmd_AddCommand ("prvm_printfunction", PRVM_PrintFunction_f);
|
||||
|
||||
Cmd_AddCommand ("prvm_edict", PRVM_ED_PrintEdict_f, "print all data about an entity number in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_edicts", PRVM_ED_PrintEdicts_f, "set a property on an entity number in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_edictcount", PRVM_ED_Count_f, "prints number of active entities in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_profile", PRVM_Profile_f, "prints execution statistics about the most used QuakeC functions in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_fields", PRVM_Fields_f, "prints usage statistics on properties (how many entities have non-zero values) in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_globals", PRVM_Globals_f, "prints all global variables in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_global", PRVM_Global_f, "prints value of a specified global variable in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_globalset", PRVM_GlobalSet_f, "sets value of a specified global variable in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_edictset", PRVM_ED_EdictSet_f, "changes value of a specified property of a specified entity in the selected VM (server, client, menu)");
|
||||
Cmd_AddCommand ("prvm_printfunction", PRVM_PrintFunction_f, "prints a disassembly (QuakeC instructions) of the specified function in the selected VM (server, client, menu)");
|
||||
// LordHavoc: optional runtime bounds checking (speed drain, but worth it for security, on by default - breaks most QCCX features (used by CRMod and others))
|
||||
prvm_boundscheck = Cvar_Get ("prvm_boundscheck", "0", 0);
|
||||
prvm_traceqc = Cvar_Get ("prvm_traceqc", "0", 0);
|
||||
|
|
|
@ -194,10 +194,6 @@ SOURCE=.\host.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\in_win.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\common\md4.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
@ -302,10 +298,6 @@ SOURCE=.\system.c
|
|||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vid_dll.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\vid_menu.c
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
|
|
@ -58,13 +58,7 @@ typedef struct host_parm_s
|
|||
{
|
||||
host_state state; // global host state
|
||||
uint type; // running at
|
||||
|
||||
bool debug; // show all warnings mode
|
||||
int developer; // show all developer's message
|
||||
|
||||
bool paused; // freeze server
|
||||
bool stuffcmdsrun; // sturtup script
|
||||
|
||||
host_redirect_t rd; // remote console
|
||||
jmp_buf abortframe; // abort current frame
|
||||
|
||||
dword framecount; // global framecount
|
||||
|
@ -73,9 +67,17 @@ typedef struct host_parm_s
|
|||
uint sv_timer; // SV_Input msg time
|
||||
uint cl_timer; // CL_Input msg time
|
||||
|
||||
uint maxclients; // host max clients
|
||||
HWND hWnd; // main window
|
||||
|
||||
host_redirect_t rd;
|
||||
bool debug; // show all warnings mode
|
||||
int developer; // show all developer's message
|
||||
|
||||
bool paused; // freeze server
|
||||
bool stuffcmdsrun; // sturtup script
|
||||
|
||||
|
||||
|
||||
uint maxclients; // host max clients
|
||||
|
||||
} host_parm_t;
|
||||
|
||||
|
@ -106,6 +108,7 @@ Host Interface
|
|||
===========================================
|
||||
*/
|
||||
extern host_parm_t host;
|
||||
long _stdcall Host_WndProc( HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam);
|
||||
void Host_Init ( uint funcname, int argc, char **argv );
|
||||
void Host_Main ( void );
|
||||
void Host_Free ( void );
|
||||
|
@ -132,9 +135,8 @@ double Sys_DoubleTime( void );
|
|||
void Sys_Error( const char *msg, ... );
|
||||
void Sys_SendKeyEvents( void );
|
||||
|
||||
//
|
||||
// in_win.c
|
||||
//
|
||||
// mouse support
|
||||
#define WM_MOUSEWHEEL (WM_MOUSELAST + 1) // message that will be supported by the OS
|
||||
extern int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
|
||||
|
||||
// vm_exec.c
|
||||
|
@ -207,18 +209,18 @@ int Cmd_Argc( void );
|
|||
char *Cmd_Args( void );
|
||||
char *Cmd_Argv( int arg );
|
||||
void Cmd_Init( int argc, char **argv );
|
||||
void _Cmd_AddCommand(const char *cmd_name, xcommand_t function, const char *cmd_desc);
|
||||
void Cmd_AddCommand(const char *cmd_name, xcommand_t function, const char *cmd_desc);
|
||||
void Cmd_RemoveCommand (char *cmd_name);
|
||||
bool Cmd_Exists (const char *cmd_name);
|
||||
void Cmd_CommandCompletion( void(*callback)(const char *s, const char *m));
|
||||
bool Cmd_GetMapList (const char *s, char *completedname, int completednamebufferlength );
|
||||
bool Cmd_GetDemoList (const char *s, char *completedname, int completednamebufferlength);
|
||||
bool Cmd_GetMapList( const char *s, char *completedname, int length );
|
||||
bool Cmd_GetDemoList( const char *s, char *completedname, int length );
|
||||
bool Cmd_GetMovieList (const char *s, char *completedname, int length );
|
||||
void Cmd_TokenizeString (const char *text);
|
||||
void Cmd_ExecuteString (const char *text);
|
||||
void Cmd_ForwardToServer (void);
|
||||
|
||||
// get rid of this
|
||||
#define Cmd_AddCommand(name, func) _Cmd_AddCommand(name, func, "no description" )
|
||||
#define Cvar_Get(name, value, flags) _Cvar_Get( name, value, flags, "no description" )
|
||||
|
||||
#endif//ENGINE_H
|
481
engine/host.c
481
engine/host.c
|
@ -6,7 +6,10 @@
|
|||
#include <setjmp.h>
|
||||
#include "engine.h"
|
||||
|
||||
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ))
|
||||
|
||||
physic_exp_t *Phys;
|
||||
render_exp_t *re;
|
||||
host_parm_t host; // host parms
|
||||
stdlib_api_t std;
|
||||
|
||||
|
@ -14,11 +17,12 @@ byte *zonepool;
|
|||
int ActiveApp;
|
||||
bool Minimized;
|
||||
char *buildstring = __TIME__ " " __DATE__;
|
||||
viddef_t viddef;
|
||||
|
||||
void Key_Init (void);
|
||||
|
||||
HINSTANCE global_hInstance;
|
||||
dll_info_t physic_dll = { "physic.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(physic_exp_t) };
|
||||
dll_info_t render_dll = { "render.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(render_exp_t) };
|
||||
|
||||
cvar_t *timescale;
|
||||
cvar_t *fixedtime;
|
||||
|
@ -26,6 +30,60 @@ cvar_t *dedicated;
|
|||
|
||||
cvar_t *host_serverstate;
|
||||
cvar_t *host_frametime;
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *r_xpos; // X coordinate of window position
|
||||
cvar_t *r_ypos; // Y coordinate of window position
|
||||
cvar_t *r_fullscreen;
|
||||
|
||||
/*
|
||||
=======
|
||||
Host_MapKey
|
||||
|
||||
Map from windows to engine keynums
|
||||
=======
|
||||
*/
|
||||
static int Host_MapKey( int key )
|
||||
{
|
||||
int result, modified;
|
||||
bool is_extended = false;
|
||||
|
||||
modified = ( key >> 16 ) & 255;
|
||||
if( modified > 127 ) return 0;
|
||||
|
||||
if ( key & ( 1 << 24 ))
|
||||
is_extended = true;
|
||||
|
||||
result = scan_to_key[modified];
|
||||
|
||||
if( !is_extended )
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case K_HOME: return K_KP_HOME;
|
||||
case K_UPARROW: return K_KP_UPARROW;
|
||||
case K_PGUP: return K_KP_PGUP;
|
||||
case K_LEFTARROW: return K_KP_LEFTARROW;
|
||||
case K_RIGHTARROW: return K_KP_RIGHTARROW;
|
||||
case K_END: return K_KP_END;
|
||||
case K_DOWNARROW: return K_KP_DOWNARROW;
|
||||
case K_PGDN: return K_KP_PGDN;
|
||||
case K_INS: return K_KP_INS;
|
||||
case K_DEL: return K_KP_DEL;
|
||||
default: return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case K_PAUSE: return K_KP_NUMLOCK;
|
||||
case 0x0D: return K_KP_ENTER;
|
||||
case 0x2F: return K_KP_SLASH;
|
||||
case 0xAF: return K_KP_PLUS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
stdlib_api_t Host_GetStdio( bool crash_on_error )
|
||||
{
|
||||
|
@ -60,7 +118,7 @@ void Host_FreeCommon( void )
|
|||
void Host_InitPhysic( void )
|
||||
{
|
||||
static physic_imp_t pi;
|
||||
launch_t CreatePhys;
|
||||
launch_t CreatePhysic;
|
||||
stdlib_api_t io = Host_GetStdio( false );
|
||||
|
||||
// phys callback
|
||||
|
@ -69,8 +127,8 @@ void Host_InitPhysic( void )
|
|||
|
||||
Sys_LoadLibrary( &physic_dll );
|
||||
|
||||
CreatePhys = (void *)physic_dll.main;
|
||||
Phys = CreatePhys( &io, &pi );
|
||||
CreatePhysic = (void *)physic_dll.main;
|
||||
Phys = CreatePhysic( &io, &pi );
|
||||
|
||||
Phys->Init();
|
||||
}
|
||||
|
@ -80,10 +138,95 @@ void Host_FreePhysic( void )
|
|||
if(physic_dll.link)
|
||||
{
|
||||
Phys->Shutdown();
|
||||
memset( &Phys, 0, sizeof(Phys));
|
||||
}
|
||||
Sys_FreeLibrary( &physic_dll );
|
||||
}
|
||||
|
||||
typedef struct vidmode_s
|
||||
{
|
||||
const char *description;
|
||||
int width, height;
|
||||
int mode;
|
||||
} vidmode_t;
|
||||
|
||||
vidmode_t vid_modes[] =
|
||||
{
|
||||
{ "Mode 0: 640x480", 640, 480, 1 },
|
||||
{ "Mode 1: 800x600", 800, 600, 2 },
|
||||
{ "Mode 2: 1024x768", 1024, 768, 3 },
|
||||
{ "Mode 3: 1280x960", 1280, 960, 4 },
|
||||
{ "Mode 4: 1280x1024", 1280, 1024, 5 },
|
||||
{ "Mode 5: 1600x1200", 1600, 1200, 6 },
|
||||
{ "Mode 6: 2048x1536", 2048, 1536, 7 }
|
||||
};
|
||||
|
||||
bool VID_GetModeInfo( int *width, int *height, int mode )
|
||||
{
|
||||
if ( mode < 0 || mode >= VID_NUM_MODES )
|
||||
return false;
|
||||
|
||||
*width = vid_modes[mode].width;
|
||||
*height = vid_modes[mode].height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void VID_NewWindow ( int width, int height)
|
||||
{
|
||||
viddef.width = width;
|
||||
viddef.height = height;
|
||||
|
||||
cl.force_refdef = true; // can't use a paused refdef
|
||||
}
|
||||
|
||||
void Host_InitRender( void )
|
||||
{
|
||||
static render_imp_t ri;
|
||||
stdlib_api_t io = Host_GetStdio( false );
|
||||
launch_t CreateRender;
|
||||
|
||||
ri.api_size = sizeof(render_imp_t);
|
||||
|
||||
// console interaction
|
||||
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.Cvar_Get = _Cvar_Get;
|
||||
ri.Cvar_Set = Cvar_Set;
|
||||
ri.Cvar_SetValue = Cvar_SetValue;
|
||||
|
||||
// studio callbacks
|
||||
ri.StudioEvent = CL_StudioEvent;
|
||||
ri.ShowCollision = Phys->ShowCollision;
|
||||
|
||||
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
||||
ri.Vid_MenuInit = VID_MenuInit;
|
||||
ri.Vid_NewWindow = VID_NewWindow;
|
||||
|
||||
Sys_LoadLibrary( &render_dll );
|
||||
|
||||
CreateRender = (void *)render_dll.main;
|
||||
re = CreateRender( &io, &ri );
|
||||
|
||||
if(!re->Init(GetModuleHandle(NULL), Host_WndProc ))
|
||||
Sys_Error("VID_InitRender: can't init render.dll\nUpdate your opengl drivers\n");
|
||||
|
||||
CL_Snd_Restart_f();
|
||||
}
|
||||
|
||||
void Host_FreeRender( void )
|
||||
{
|
||||
if(render_dll.link)
|
||||
{
|
||||
re->Shutdown();
|
||||
memset( &re, 0, sizeof(re));
|
||||
}
|
||||
Sys_FreeLibrary( &render_dll );
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Host_AbortCurrentFrame
|
||||
|
@ -116,67 +259,52 @@ void Host_SetServerState( int state )
|
|||
Cvar_SetValue("host_serverstate", state );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Init
|
||||
Host_VidRestart_f
|
||||
|
||||
Restart the video subsystem
|
||||
=================
|
||||
*/
|
||||
void Host_Init (uint funcname, int argc, char **argv)
|
||||
void Host_VidRestart_f( void )
|
||||
{
|
||||
char *s;
|
||||
cl.force_refdef = true; // can't use a paused refdef
|
||||
S_StopAllSounds(); // don't let them loop during the restart
|
||||
cl.refresh_prepped = false;
|
||||
|
||||
host.state = HOST_INIT; //initialzation started
|
||||
Host_FreeRender(); // release render.dll
|
||||
Host_InitRender(); // load it again
|
||||
}
|
||||
|
||||
global_hInstance = (HINSTANCE)GetModuleHandle( NULL );
|
||||
host.type = funcname;
|
||||
/*
|
||||
============
|
||||
VID_Init
|
||||
============
|
||||
*/
|
||||
void VID_Init( void )
|
||||
{
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "1", CVAR_ARCHIVE );
|
||||
Cmd_AddCommand ("vid_restart", Host_VidRestart_f, "restarts video system" );
|
||||
|
||||
srand(time(NULL)); // init random generator
|
||||
Host_InitRender();
|
||||
}
|
||||
|
||||
Host_InitCommon( funcname, argc, argv ); // loading common.dll
|
||||
Cmd_Init( argc, argv );
|
||||
Cvar_Init();
|
||||
Key_Init();
|
||||
PRVM_Init();
|
||||
/*
|
||||
==================
|
||||
VID_AppActivate
|
||||
==================
|
||||
*/
|
||||
void VID_AppActivate(BOOL fActive, BOOL minimize)
|
||||
{
|
||||
Minimized = minimize;
|
||||
|
||||
// get default configuration
|
||||
#if 1
|
||||
Cbuf_AddText("exec keys.rc\n");
|
||||
Cbuf_AddText("exec vars.rc\n");
|
||||
#else
|
||||
Cbuf_AddText("exec default.cfg\n");
|
||||
Cbuf_AddText("exec config.cfg\n");
|
||||
#endif
|
||||
Cbuf_Execute();
|
||||
Key_ClearStates(); // FIXME!!!
|
||||
|
||||
// init commands and vars
|
||||
Cmd_AddCommand ("error", Host_Error_f);
|
||||
if (fActive && !Minimized ) ActiveApp = true;
|
||||
else ActiveApp = false;
|
||||
|
||||
host_frametime = Cvar_Get ("host_frametime", "0.01", 0);
|
||||
host_serverstate = Cvar_Get ("host_serverstate", "0", 0);
|
||||
timescale = Cvar_Get ("timescale", "1", 0);
|
||||
fixedtime = Cvar_Get ("fixedtime", "0", 0);
|
||||
if(host.type == HOST_DEDICATED) dedicated = Cvar_Get ("dedicated", "1", CVAR_INIT);
|
||||
else dedicated = Cvar_Get ("dedicated", "0", CVAR_INIT);
|
||||
|
||||
s = va("^1Xash %g ^3%s", XASH_VERSION, buildstring );
|
||||
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_INIT);
|
||||
|
||||
if (dedicated->value) Cmd_AddCommand ("quit", Sys_Quit);
|
||||
|
||||
NET_Init();
|
||||
Netchan_Init();
|
||||
Host_InitPhysic();
|
||||
|
||||
SV_Init();
|
||||
CL_Init();
|
||||
|
||||
Cbuf_AddText("exec init.rc\n");
|
||||
Cbuf_Execute();
|
||||
|
||||
// if stuffcmds wasn't run, then init.rc is probably missing, use default
|
||||
if(!host.stuffcmdsrun) Cbuf_ExecuteText( EXEC_NOW, "stuffcmds\n" );
|
||||
Sys_DoubleTime(); // initialize timer
|
||||
if (!ActiveApp ) IN_Activate( false );
|
||||
else IN_Activate( true );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -184,7 +312,7 @@ void Host_Init (uint funcname, int argc, char **argv)
|
|||
Host_Frame
|
||||
=================
|
||||
*/
|
||||
void Host_Frame (double time)
|
||||
void Host_Frame( double time )
|
||||
{
|
||||
char *s;
|
||||
|
||||
|
@ -214,43 +342,116 @@ void Host_Frame (double time)
|
|||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Main
|
||||
=================
|
||||
====================
|
||||
MainWndProc
|
||||
|
||||
main window procedure
|
||||
====================
|
||||
*/
|
||||
void Host_Main( void )
|
||||
long _stdcall Host_WndProc( HWND hWnd, uint uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static double time, oldtime, newtime;
|
||||
int i, zDelta, temp = 0;
|
||||
|
||||
oldtime = host.realtime;
|
||||
|
||||
// main window message loop
|
||||
while (host.type != HOST_OFFLINE)
|
||||
switch (uMsg)
|
||||
{
|
||||
oldtime = newtime;
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
case WM_MOUSEWHEEL:
|
||||
//if(m_mouse->integer != 1 || (!r_fullscreen->integer && (cls.key_dest == key_console)))
|
||||
{
|
||||
zDelta = (short)HIWORD( wParam ) / 120;
|
||||
if( zDelta > 0 )
|
||||
{
|
||||
for(i = 0; i < zDelta; i++)
|
||||
{
|
||||
Key_Event( K_MWHEELUP, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELUP, false, host.sv_timer );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(i = 0; i < -zDelta; i++)
|
||||
{
|
||||
Key_Event( K_MWHEELDOWN, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELDOWN, false, host.sv_timer );
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
case WM_CREATE:
|
||||
host.hWnd = hWnd;
|
||||
r_xpos = Cvar_Get ("r_xpos", "3", CVAR_ARCHIVE );
|
||||
r_ypos = Cvar_Get ("r_ypos", "22", CVAR_ARCHIVE );
|
||||
r_fullscreen = Cvar_Get ("r_fullscreen", "1", CVAR_ARCHIVE | CVAR_LATCH );
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
host.hWnd = NULL;
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
Cbuf_ExecuteText( EXEC_APPEND, "quit" );
|
||||
break;
|
||||
case WM_ACTIVATE:
|
||||
VID_AppActivate(LOWORD(wParam) != WA_INACTIVE, (BOOL) HIWORD(wParam));
|
||||
SNDDMA_Activate();
|
||||
if( render_dll.link ) re->AppActivate( LOWORD(wParam) != WA_INACTIVE);
|
||||
break;
|
||||
case WM_MOVE:
|
||||
if (!r_fullscreen->integer )
|
||||
{
|
||||
RECT r;
|
||||
int xPos, yPos, style;
|
||||
|
||||
Host_Frame (time); // engine frame
|
||||
xPos = (short) LOWORD(lParam); // horizontal position
|
||||
yPos = (short) HIWORD(lParam); // vertical position
|
||||
|
||||
r.left = r.top = 0;
|
||||
r.right = r.bottom = 1;
|
||||
style = GetWindowLong( hWnd, GWL_STYLE );
|
||||
AdjustWindowRect( &r, style, FALSE );
|
||||
|
||||
Cvar_SetValue( "r_xpos", xPos + r.left);
|
||||
Cvar_SetValue( "r_ypos", yPos + r.top);
|
||||
r_xpos->modified = false;
|
||||
r_ypos->modified = false;
|
||||
if (ActiveApp) IN_Activate( true );
|
||||
}
|
||||
break;
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_MOUSEMOVE:
|
||||
if(wParam & MK_LBUTTON) temp |= 1;
|
||||
if(wParam & MK_RBUTTON) temp |= 2;
|
||||
if(wParam & MK_MBUTTON) temp |= 4;
|
||||
IN_MouseEvent( temp );
|
||||
break;
|
||||
case WM_SYSCOMMAND:
|
||||
if( wParam == SC_SCREENSAVE ) return 0;
|
||||
break;
|
||||
case WM_SYSKEYDOWN:
|
||||
if( wParam == 13 )
|
||||
{
|
||||
if( r_fullscreen ) Cvar_SetValue( "r_fullscreen", !r_fullscreen->value );
|
||||
return 0;
|
||||
}
|
||||
// intentional fallthrough
|
||||
case WM_KEYDOWN:
|
||||
Key_Event( Host_MapKey( lParam ), true, host.sv_timer);
|
||||
break;
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
Key_Event( Host_MapKey( lParam ), false, host.sv_timer);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
CL_CharEvent( wParam );
|
||||
break;
|
||||
}
|
||||
host.state = HOST_SHUTDOWN;
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Shutdown
|
||||
=================
|
||||
*/
|
||||
void Host_Free( void )
|
||||
{
|
||||
SV_Shutdown ("Server shutdown\n", false);
|
||||
CL_Shutdown ();
|
||||
NET_Shutdown();
|
||||
Host_FreePhysic();
|
||||
Host_FreeCommon();
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
Host_Print
|
||||
|
@ -404,5 +605,119 @@ void Host_Error( const char *error, ... )
|
|||
|
||||
void Host_Error_f( void )
|
||||
{
|
||||
Host_Error( "%s\n", Cmd_Argv(1));
|
||||
if( Cmd_Argc() == 1 ) Sys_Error( "break\n" );
|
||||
else Sys_Error( "%s\n", Cmd_Argv( 1 ));
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Crash_f
|
||||
=================
|
||||
*/
|
||||
static void Host_Crash_f (void)
|
||||
{
|
||||
*(int *)0 = 0xffffffff;
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Init
|
||||
=================
|
||||
*/
|
||||
void Host_Init (uint funcname, int argc, char **argv)
|
||||
{
|
||||
char *s;
|
||||
|
||||
host.state = HOST_INIT; // initialzation started
|
||||
host.type = funcname;
|
||||
|
||||
srand(time(NULL)); // init random generator
|
||||
|
||||
Host_InitCommon( funcname, argc, argv ); // loading common.dll
|
||||
Cmd_Init( argc, argv );
|
||||
Cvar_Init();
|
||||
Key_Init();
|
||||
PRVM_Init();
|
||||
|
||||
// get default configuration
|
||||
#if 1
|
||||
Cbuf_AddText("exec keys.rc\n");
|
||||
Cbuf_AddText("exec vars.rc\n");
|
||||
#else
|
||||
Cbuf_AddText("exec default.cfg\n");
|
||||
Cbuf_AddText("exec config.cfg\n");
|
||||
#endif
|
||||
Cbuf_Execute();
|
||||
|
||||
// init commands and vars
|
||||
if(host.developer)
|
||||
{
|
||||
Cmd_AddCommand ("error", Host_Error_f, "just throw a fatal error to test shutdown procedures" );
|
||||
Cmd_AddCommand ("crash", Host_Crash_f, "a way to force a bus error for development reasons");
|
||||
}
|
||||
|
||||
host_frametime = Cvar_Get ("host_frametime", "0.01", 0);
|
||||
host_serverstate = Cvar_Get ("host_serverstate", "0", 0);
|
||||
timescale = Cvar_Get ("timescale", "1", 0);
|
||||
fixedtime = Cvar_Get ("fixedtime", "0", 0);
|
||||
if(host.type == HOST_DEDICATED) dedicated = Cvar_Get ("dedicated", "1", CVAR_INIT);
|
||||
else dedicated = Cvar_Get ("dedicated", "0", CVAR_INIT);
|
||||
|
||||
s = va("^1Xash %g ^3%s", XASH_VERSION, buildstring );
|
||||
Cvar_Get ("version", s, CVAR_SERVERINFO|CVAR_INIT);
|
||||
|
||||
if(dedicated->value) Cmd_AddCommand ("quit", Sys_Quit, "quit the game" );
|
||||
|
||||
NET_Init();
|
||||
Netchan_Init();
|
||||
Host_InitPhysic();
|
||||
|
||||
SV_Init();
|
||||
CL_Init();
|
||||
|
||||
Cbuf_AddText("exec init.rc\n");
|
||||
Cbuf_Execute();
|
||||
|
||||
// if stuffcmds wasn't run, then init.rc is probably missing, use default
|
||||
if(!host.stuffcmdsrun) Cbuf_ExecuteText( EXEC_NOW, "stuffcmds\n" );
|
||||
Sys_DoubleTime(); // initialize timer
|
||||
}
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Main
|
||||
=================
|
||||
*/
|
||||
void Host_Main( void )
|
||||
{
|
||||
static double time, oldtime, newtime;
|
||||
|
||||
oldtime = host.realtime;
|
||||
|
||||
// main window message loop
|
||||
while (host.type != HOST_OFFLINE)
|
||||
{
|
||||
oldtime = newtime;
|
||||
newtime = Sys_DoubleTime();
|
||||
time = newtime - oldtime;
|
||||
|
||||
Host_Frame( time ); // engine frame
|
||||
}
|
||||
host.state = HOST_SHUTDOWN;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=================
|
||||
Host_Shutdown
|
||||
=================
|
||||
*/
|
||||
void Host_Free( void )
|
||||
{
|
||||
SV_Shutdown("Server shutdown\n", false );
|
||||
CL_Shutdown();
|
||||
Host_FreeRender();
|
||||
NET_Shutdown();
|
||||
Host_FreePhysic();
|
||||
Host_FreeCommon();
|
||||
}
|
379
engine/in_win.c
379
engine/in_win.c
|
@ -1,379 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// in_win.c -- windows 95 mouse code
|
||||
// 02/21/97 JCB Added extended DirectInput code to support external controllers.
|
||||
|
||||
#include "engine.h"
|
||||
#include "client.h"
|
||||
|
||||
extern HWND cl_hwnd;
|
||||
extern bool ActiveApp, Minimized;
|
||||
|
||||
cvar_t *in_mouse;
|
||||
|
||||
bool in_appactive;
|
||||
|
||||
/*
|
||||
============================================================
|
||||
|
||||
MOUSE CONTROL
|
||||
|
||||
============================================================
|
||||
*/
|
||||
|
||||
// mouse variables
|
||||
cvar_t *m_filter;
|
||||
|
||||
bool mlooking;
|
||||
|
||||
void IN_MLookDown (void)
|
||||
{
|
||||
mlooking = true;
|
||||
}
|
||||
|
||||
void IN_MLookUp (void)
|
||||
{
|
||||
mlooking = false;
|
||||
if (!freelook->value && lookspring->value)
|
||||
IN_CenterView ();
|
||||
}
|
||||
|
||||
int mouse_buttons;
|
||||
int mouse_oldbuttonstate;
|
||||
POINT current_pos;
|
||||
int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum;
|
||||
|
||||
int old_x, old_y;
|
||||
|
||||
bool mouseactive; // false when not focus app
|
||||
|
||||
bool restore_spi;
|
||||
bool mouseinitialized;
|
||||
int originalmouseparms[3], newmouseparms[3] = {0, 0, 1};
|
||||
bool mouseparmsvalid;
|
||||
|
||||
int window_center_x, window_center_y;
|
||||
RECT window_rect;
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_ActivateMouse
|
||||
|
||||
Called when the window gains focus or changes in some way
|
||||
===========
|
||||
*/
|
||||
void IN_ActivateMouse (void)
|
||||
{
|
||||
int width, height;
|
||||
|
||||
if (!mouseinitialized)
|
||||
return;
|
||||
if (!in_mouse->value)
|
||||
{
|
||||
mouseactive = false;
|
||||
return;
|
||||
}
|
||||
if (mouseactive)
|
||||
return;
|
||||
|
||||
mouseactive = true;
|
||||
|
||||
if (mouseparmsvalid)
|
||||
restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0);
|
||||
|
||||
width = GetSystemMetrics (SM_CXSCREEN);
|
||||
height = GetSystemMetrics (SM_CYSCREEN);
|
||||
|
||||
GetWindowRect ( cl_hwnd, &window_rect);
|
||||
if (window_rect.left < 0)
|
||||
window_rect.left = 0;
|
||||
if (window_rect.top < 0)
|
||||
window_rect.top = 0;
|
||||
if (window_rect.right >= width)
|
||||
window_rect.right = width-1;
|
||||
if (window_rect.bottom >= height-1)
|
||||
window_rect.bottom = height-1;
|
||||
|
||||
window_center_x = (window_rect.right + window_rect.left)/2;
|
||||
window_center_y = (window_rect.top + window_rect.bottom)/2;
|
||||
|
||||
SetCursorPos (window_center_x, window_center_y);
|
||||
|
||||
old_x = window_center_x;
|
||||
old_y = window_center_y;
|
||||
|
||||
SetCapture ( cl_hwnd );
|
||||
ClipCursor (&window_rect);
|
||||
while (ShowCursor (FALSE) >= 0);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_DeactivateMouse
|
||||
|
||||
Called when the window loses focus
|
||||
===========
|
||||
*/
|
||||
void IN_DeactivateMouse (void)
|
||||
{
|
||||
if (!mouseinitialized)
|
||||
return;
|
||||
if (!mouseactive)
|
||||
return;
|
||||
|
||||
if (restore_spi)
|
||||
SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0);
|
||||
|
||||
mouseactive = false;
|
||||
|
||||
ClipCursor (NULL);
|
||||
ReleaseCapture ();
|
||||
while (ShowCursor (TRUE) < 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_StartupMouse
|
||||
===========
|
||||
*/
|
||||
void IN_StartupMouse (void)
|
||||
{
|
||||
cvar_t *cv;
|
||||
|
||||
cv = Cvar_Get ("in_initmouse", "1", CVAR_INIT);
|
||||
if ( !cv->value )
|
||||
return;
|
||||
|
||||
mouseinitialized = true;
|
||||
mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0);
|
||||
mouse_buttons = 3;
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_MouseEvent
|
||||
===========
|
||||
*/
|
||||
void IN_MouseEvent (int mstate)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (!mouseinitialized)
|
||||
return;
|
||||
|
||||
// perform button actions
|
||||
for (i=0 ; i<mouse_buttons ; i++)
|
||||
{
|
||||
if ( (mstate & (1<<i)) &&
|
||||
!(mouse_oldbuttonstate & (1<<i)) )
|
||||
{
|
||||
Key_Event (K_MOUSE1 + i, true, host.sv_timer);
|
||||
}
|
||||
|
||||
if ( !(mstate & (1<<i)) &&
|
||||
(mouse_oldbuttonstate & (1<<i)) )
|
||||
{
|
||||
Key_Event (K_MOUSE1 + i, false, host.sv_timer);
|
||||
}
|
||||
}
|
||||
|
||||
mouse_oldbuttonstate = mstate;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_MouseMove
|
||||
===========
|
||||
*/
|
||||
void IN_MouseMove (usercmd_t *cmd)
|
||||
{
|
||||
int mx, my;
|
||||
|
||||
if (!mouseactive)
|
||||
return;
|
||||
|
||||
// find mouse movement
|
||||
if (!GetCursorPos (¤t_pos))
|
||||
return;
|
||||
|
||||
mx = current_pos.x - window_center_x;
|
||||
my = current_pos.y - window_center_y;
|
||||
|
||||
#if 0
|
||||
if (!mx && !my)
|
||||
return;
|
||||
#endif
|
||||
|
||||
if (m_filter->value)
|
||||
{
|
||||
mouse_x = (mx + old_mouse_x) * 0.5;
|
||||
mouse_y = (my + old_mouse_y) * 0.5;
|
||||
}
|
||||
else
|
||||
{
|
||||
mouse_x = mx;
|
||||
mouse_y = my;
|
||||
}
|
||||
|
||||
old_mouse_x = mx;
|
||||
old_mouse_y = my;
|
||||
|
||||
mouse_x *= sensitivity->value;
|
||||
mouse_y *= sensitivity->value;
|
||||
|
||||
// add mouse X/Y movement to cmd
|
||||
if ( (in_strafe.state & 1) || (lookstrafe->value && mlooking ))
|
||||
cmd->sidemove += m_side->value * mouse_x;
|
||||
else
|
||||
cl.viewangles[YAW] -= m_yaw->value * mouse_x;
|
||||
|
||||
if ( (mlooking || freelook->value) && !(in_strafe.state & 1))
|
||||
{
|
||||
cl.viewangles[PITCH] += m_pitch->value * mouse_y;
|
||||
}
|
||||
else
|
||||
{
|
||||
cmd->forwardmove -= m_forward->value * mouse_y;
|
||||
}
|
||||
|
||||
// force the mouse to the center, so there's room to move
|
||||
if (mx || my)
|
||||
SetCursorPos (window_center_x, window_center_y);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
=========================================================================
|
||||
|
||||
VIEW CENTERING
|
||||
|
||||
=========================================================================
|
||||
*/
|
||||
|
||||
cvar_t *v_centermove;
|
||||
cvar_t *v_centerspeed;
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Init
|
||||
===========
|
||||
*/
|
||||
void IN_Init (void)
|
||||
{
|
||||
// mouse variables
|
||||
m_filter = Cvar_Get ("m_filter", "0", 0);
|
||||
in_mouse = Cvar_Get ("in_mouse", "1", CVAR_ARCHIVE);
|
||||
|
||||
// centering
|
||||
v_centermove = Cvar_Get ("v_centermove", "0.15", 0);
|
||||
v_centerspeed = Cvar_Get ("v_centerspeed", "500", 0);
|
||||
|
||||
Cmd_AddCommand ("+mlook", IN_MLookDown);
|
||||
Cmd_AddCommand ("-mlook", IN_MLookUp);
|
||||
|
||||
IN_StartupMouse ();
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Shutdown
|
||||
===========
|
||||
*/
|
||||
void IN_Shutdown (void)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Activate
|
||||
|
||||
Called when the main window gains or loses focus.
|
||||
The window may have been destroyed and recreated
|
||||
between a deactivate and an activate.
|
||||
===========
|
||||
*/
|
||||
void IN_Activate (bool active)
|
||||
{
|
||||
in_appactive = active;
|
||||
mouseactive = !active; // force a new window check or turn off
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
IN_Frame
|
||||
|
||||
Called every frame, even if not generating commands
|
||||
==================
|
||||
*/
|
||||
void IN_Frame (void)
|
||||
{
|
||||
if (!mouseinitialized)
|
||||
return;
|
||||
|
||||
if (!in_mouse || !in_appactive)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
return;
|
||||
}
|
||||
|
||||
if ( !cl.refresh_prepped || cls.key_dest == key_console || cls.key_dest == key_menu)
|
||||
{
|
||||
// temporarily deactivate if in fullscreen
|
||||
if (Cvar_VariableValue ("vid_fullscreen") == 0)
|
||||
{
|
||||
IN_DeactivateMouse ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
IN_ActivateMouse ();
|
||||
}
|
||||
|
||||
/*
|
||||
===========
|
||||
IN_Move
|
||||
===========
|
||||
*/
|
||||
void IN_Move (usercmd_t *cmd)
|
||||
{
|
||||
IN_MouseMove (cmd);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===================
|
||||
IN_ClearStates
|
||||
===================
|
||||
*/
|
||||
void IN_ClearStates (void)
|
||||
{
|
||||
mx_accum = 0;
|
||||
my_accum = 0;
|
||||
mouse_oldbuttonstate = 0;
|
||||
}
|
|
@ -71,7 +71,6 @@ typedef struct
|
|||
{
|
||||
sv_state_t state; // precache commands are only valid during load
|
||||
|
||||
bool attractloop; // running cinematics and demos for the local system only
|
||||
bool loadgame; // client begins should reuse existing entity
|
||||
|
||||
float time; // always sv.framenum * 100 msec
|
||||
|
@ -239,7 +238,8 @@ int SV_DecalIndex (const char *name);
|
|||
|
||||
void SV_WriteClientdataToMessage (client_state_t *client, sizebuf_t *msg);
|
||||
void SV_ExecuteUserCommand (char *s);
|
||||
void SV_InitOperatorCommands (void);
|
||||
void SV_InitOperatorCommands( void );
|
||||
void SV_KillOperatorCommands( void );
|
||||
void SV_SendServerinfo (client_state_t *client);
|
||||
void SV_UserinfoChanged (client_state_t *cl);
|
||||
void Master_Heartbeat (void);
|
||||
|
@ -249,7 +249,8 @@ void Master_Packet (void);
|
|||
// sv_init.c
|
||||
//
|
||||
void SV_InitGame (void);
|
||||
void SV_Map (bool attractloop, char *levelstring, char *savename, bool loadgame);
|
||||
void SV_Map(char *levelstring, char *savename );
|
||||
void SV_SpawnServer (char *server, char *savename, sv_state_t serverstate );
|
||||
int SV_FindIndex (const char *name, int start, int end, bool create);
|
||||
void SV_VM_Setup(void);
|
||||
void SV_VM_Begin(void);
|
||||
|
@ -323,7 +324,7 @@ int SV_StudioExtractBbox( studiohdr_t *phdr, int sequence, float *mins, float *m
|
|||
//
|
||||
// sv_spawn.c
|
||||
//
|
||||
void SV_SpawnEntities (char *mapname, char *entities, char *spawnpoint);
|
||||
void SV_SpawnEntities (char *mapname, char *entities);
|
||||
void SV_StartParticle (vec3_t org, vec3_t dir, int color, int count);
|
||||
void SV_Transform( sv_edict_t *ed, vec3_t origin, vec3_t angles );
|
||||
void SV_FreeEdict (edict_t *ed);
|
||||
|
|
|
@ -1,36 +1,12 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
//=======================================================================
|
||||
// Copyright XashXT Group 2007 ©
|
||||
// sv_cmds.c - server console commands
|
||||
//=======================================================================
|
||||
|
||||
#include "engine.h"
|
||||
#include "server.h"
|
||||
#include "savefile.h"
|
||||
|
||||
/*
|
||||
===============================================================================
|
||||
|
||||
OPERATOR CONSOLE ONLY COMMANDS
|
||||
|
||||
These commands can only be entered from stdin or by a remote operator datagram
|
||||
===============================================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
====================
|
||||
SV_SetMaster_f
|
||||
|
@ -38,51 +14,44 @@ SV_SetMaster_f
|
|||
Specify a list of master servers
|
||||
====================
|
||||
*/
|
||||
void SV_SetMaster_f (void)
|
||||
void SV_SetMaster_f( void )
|
||||
{
|
||||
int i, slot;
|
||||
|
||||
// only dedicated servers send heartbeats
|
||||
if (!dedicated->value)
|
||||
if(!dedicated->value)
|
||||
{
|
||||
Msg ("Only dedicated servers use masters.\n");
|
||||
Msg("Only dedicated servers use masters.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure the server is listed public
|
||||
Cvar_Set ("public", "1");
|
||||
|
||||
for (i=1 ; i<MAX_MASTERS ; i++)
|
||||
memset (&master_adr[i], 0, sizeof(master_adr[i]));
|
||||
for (i = 1; i < MAX_MASTERS; i++)
|
||||
{
|
||||
memset(&master_adr[i], 0, sizeof(master_adr[i]));
|
||||
}
|
||||
|
||||
slot = 1; // slot 0 will always contain the id master
|
||||
for (i=1 ; i<Cmd_Argc() ; i++)
|
||||
// slot 0 will always contain the id master
|
||||
for (i = 1, slot = 1; i < Cmd_Argc(); i++)
|
||||
{
|
||||
if (slot == MAX_MASTERS)
|
||||
break;
|
||||
|
||||
if (slot == MAX_MASTERS) break;
|
||||
if (!NET_StringToAdr (Cmd_Argv(i), &master_adr[i]))
|
||||
{
|
||||
Msg ("Bad address: %s\n", Cmd_Argv(i));
|
||||
continue;
|
||||
}
|
||||
if (master_adr[slot].port == 0)
|
||||
master_adr[slot].port = BigShort (PORT_MASTER);
|
||||
|
||||
if(!master_adr[slot].port) master_adr[slot].port = BigShort (PORT_MASTER);
|
||||
Msg ("Master server at %s\n", NET_AdrToString (master_adr[slot]));
|
||||
|
||||
Msg ("Sending a ping.\n");
|
||||
|
||||
Netchan_OutOfBandPrint (NS_SERVER, master_adr[slot], "ping");
|
||||
|
||||
slot++;
|
||||
}
|
||||
|
||||
svs.last_heartbeat = -99999.0f;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_SetPlayer
|
||||
|
@ -90,15 +59,13 @@ SV_SetPlayer
|
|||
Sets sv_client and sv_player to the player with idnum Cmd_Argv(1)
|
||||
==================
|
||||
*/
|
||||
bool SV_SetPlayer (void)
|
||||
bool SV_SetPlayer( void )
|
||||
{
|
||||
client_state_t *cl;
|
||||
int i;
|
||||
int idnum;
|
||||
char *s;
|
||||
client_state_t *cl;
|
||||
int i, idnum;
|
||||
|
||||
if (Cmd_Argc() < 2)
|
||||
return false;
|
||||
if(Cmd_Argc() < 2) return false;
|
||||
|
||||
s = Cmd_Argv(1);
|
||||
|
||||
|
@ -106,27 +73,25 @@ bool SV_SetPlayer (void)
|
|||
if (s[0] >= '0' && s[0] <= '9')
|
||||
{
|
||||
idnum = atoi(Cmd_Argv(1));
|
||||
if (idnum < 0 || idnum >= maxclients->value)
|
||||
if (idnum < 0 || idnum >= maxclients->integer)
|
||||
{
|
||||
Msg ("Bad client slot: %i\n", idnum);
|
||||
Msg("Bad client slot: %i\n", idnum);
|
||||
return false;
|
||||
}
|
||||
|
||||
sv_client = &svs.clients[idnum];
|
||||
sv_player = sv_client->edict;
|
||||
if (!sv_client->state)
|
||||
{
|
||||
Msg ("Client %i is not active\n", idnum);
|
||||
Msg("Client %i is not active\n", idnum);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// check for a name match
|
||||
for (i=0,cl=svs.clients ; i<maxclients->value; i++,cl++)
|
||||
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
|
||||
{
|
||||
if (!cl->state)
|
||||
continue;
|
||||
if (!cl->state) continue;
|
||||
if (!strcmp(cl->name, s))
|
||||
{
|
||||
sv_client = cl;
|
||||
|
@ -134,93 +99,10 @@ bool SV_SetPlayer (void)
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Msg ("Userid %s is not on the server\n", s);
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_DemoMap_f
|
||||
|
||||
Puts the server in demo mode on a specific map/cinematic
|
||||
==================
|
||||
*/
|
||||
void SV_DemoMap_f (void)
|
||||
{
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("USAGE: demomap <map>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
SV_Map (true, Cmd_Argv(1), NULL, false );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_GameMap_f
|
||||
|
||||
Saves the state of the map just being exited and goes to a new map.
|
||||
|
||||
If the initial character of the map string is '*', the next map is
|
||||
in a new unit, so the current savegame directory is cleared of
|
||||
map files.
|
||||
|
||||
Example:
|
||||
|
||||
*inter.cin+jail
|
||||
|
||||
Clears the archived maps, plays the inter.cin cinematic, then
|
||||
goes to map jail.bsp.
|
||||
==================
|
||||
*/
|
||||
void SV_GameMap_f (void)
|
||||
{
|
||||
char *map;
|
||||
int i;
|
||||
client_state_t *cl;
|
||||
bool *savedFree;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("USAGE: gamemap <map>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// check for clearing the current savegame
|
||||
map = Cmd_Argv(1);
|
||||
if (map[0] != '*')
|
||||
{
|
||||
// save the map just exited
|
||||
if (sv.state == ss_game)
|
||||
{
|
||||
// clear all the client free flags before saving so that
|
||||
// when the level is re-entered, the clients will spawn
|
||||
// at spawn points instead of occupying body shells
|
||||
savedFree = Z_Malloc(maxclients->value * sizeof(bool));
|
||||
for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
|
||||
{
|
||||
savedFree[i] = cl->edict->priv.sv->free;
|
||||
cl->edict->priv.sv->free = true;
|
||||
}
|
||||
|
||||
SV_WriteSaveFile( "save0" ); //autosave
|
||||
|
||||
// we must restore these for clients to transfer over correctly
|
||||
for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
|
||||
cl->edict->priv.sv->free = savedFree[i];
|
||||
Z_Free (savedFree);
|
||||
}
|
||||
}
|
||||
|
||||
// start up the next map
|
||||
SV_Map (false, Cmd_Argv(1), NULL, false );
|
||||
|
||||
// archive server state
|
||||
strncpy (svs.mapcmd, Cmd_Argv(1), sizeof(svs.mapcmd)-1);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Map_f
|
||||
|
@ -229,108 +111,222 @@ Goes directly to a given map without any savegame archiving.
|
|||
For development work
|
||||
==================
|
||||
*/
|
||||
void SV_Map_f (void)
|
||||
void SV_Map_f( void )
|
||||
{
|
||||
char *map;
|
||||
char expanded[MAX_QPATH];
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
// if not a pcx, demo, or cinematic, check to make sure the level exists
|
||||
map = Cmd_Argv(1);
|
||||
if(!strstr (map, "."))
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
sprintf(expanded, "maps/%s.bsp", map);
|
||||
if(!FS_FileExists( expanded ))
|
||||
Msg("Usage: map <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.bsp", Cmd_Argv(1));
|
||||
if(!FS_FileExists(va("maps/%s", filename )))
|
||||
{
|
||||
Msg("Can't loading %s\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
SV_InitGame(); // reset previous state
|
||||
|
||||
SV_BroadcastCommand("changing\n");
|
||||
SV_SendClientMessages();
|
||||
SV_SpawnServer( filename, NULL, ss_game );
|
||||
SV_BroadcastCommand ("reconnect\n");
|
||||
|
||||
// archive server state
|
||||
std.strncpy (svs.mapcmd, filename, sizeof(svs.mapcmd) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Demo_f
|
||||
|
||||
Playing a demo with specified name
|
||||
==================
|
||||
*/
|
||||
void SV_Demo_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg("Usage: demo <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.dem", Cmd_Argv(1));
|
||||
if(!FS_FileExists(va("demos/%s", filename )))
|
||||
{
|
||||
Msg("Can't loading %s\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
// the game is just starting
|
||||
if(sv.state == ss_dead) SV_InitGame();
|
||||
|
||||
SV_BroadcastCommand( "changing\n" );
|
||||
SV_SpawnServer(filename, NULL, ss_demo );
|
||||
SV_BroadcastCommand( "reconnect\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Movie_f
|
||||
|
||||
Playing a roq video with specified name
|
||||
==================
|
||||
*/
|
||||
void SV_Movie_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg("Usage: movie <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.roq", Cmd_Argv(1));
|
||||
if(!FS_FileExists(va("video/%s", filename )))
|
||||
{
|
||||
Msg("Can't loading %s\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
SV_InitGame();
|
||||
SV_BroadcastCommand( "changing\n" );
|
||||
SV_SpawnServer( filename, NULL, ss_cinematic );
|
||||
SV_BroadcastCommand( "reconnect\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_Load_f
|
||||
|
||||
==============
|
||||
*/
|
||||
void SV_Load_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("Usage: load <filename>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.bin", Cmd_Argv(1));
|
||||
if(!FS_FileExists(va("save/%s", filename )))
|
||||
{
|
||||
Msg("Can't loading %s\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
SV_ReadSaveFile( filename );
|
||||
SV_BroadcastCommand( "changing\n" );
|
||||
SV_SpawnServer(svs.mapcmd, filename, ss_game );
|
||||
SV_BroadcastCommand( "reconnect\n" );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_Save_f
|
||||
|
||||
==============
|
||||
*/
|
||||
void SV_Save_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("Usage: savegame <directory>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.bin", Cmd_Argv(1));
|
||||
SV_WriteSaveFile( filename );
|
||||
}
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_ChangeLevel_f
|
||||
|
||||
Saves the state of the map just being exited and goes to a new map.
|
||||
==================
|
||||
*/
|
||||
void SV_ChangeLevel_f( void )
|
||||
{
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("Usage: changelevel <map>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
std.snprintf( filename, MAX_QPATH, "%s.bsp", Cmd_Argv(1));
|
||||
if(!FS_FileExists(va("maps/%s", filename )))
|
||||
{
|
||||
Msg("Can't loading %s\n", filename );
|
||||
return;
|
||||
}
|
||||
|
||||
if(sv.state == ss_game)
|
||||
{
|
||||
bool *savedFree;
|
||||
client_state_t *cl;
|
||||
int i;
|
||||
|
||||
// clear all the client free flags before saving so that
|
||||
// when the level is re-entered, the clients will spawn
|
||||
// at spawn points instead of occupying body shells
|
||||
savedFree = Z_Malloc(maxclients->integer * sizeof(bool));
|
||||
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
|
||||
{
|
||||
Msg("Can't find %s\n", expanded);
|
||||
return;
|
||||
savedFree[i] = cl->edict->priv.sv->free;
|
||||
cl->edict->priv.sv->free = true;
|
||||
}
|
||||
SV_WriteSaveFile( "save0.bin" ); // autosave
|
||||
// we must restore these for clients to transfer over correctly
|
||||
for (i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
|
||||
cl->edict->priv.sv->free = savedFree[i];
|
||||
Z_Free(savedFree);
|
||||
}
|
||||
|
||||
sv.state = ss_dead; // don't save current level when changing
|
||||
SV_GameMap_f();
|
||||
SV_InitGame(); // reset previous state
|
||||
SV_BroadcastCommand("changing\n");
|
||||
SV_SendClientMessages();
|
||||
SV_SpawnServer( filename, NULL, ss_game );
|
||||
SV_BroadcastCommand ("reconnect\n");
|
||||
|
||||
// archive server state
|
||||
std.strncpy (svs.mapcmd, filename, sizeof(svs.mapcmd) - 1);
|
||||
}
|
||||
|
||||
/*
|
||||
=====================================================================
|
||||
==================
|
||||
SV_Restart_f
|
||||
|
||||
SAVEGAMES
|
||||
|
||||
=====================================================================
|
||||
restarts current level
|
||||
==================
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_Loadgame_f
|
||||
|
||||
==============
|
||||
*/
|
||||
void SV_Loadgame_f (void)
|
||||
void SV_Restart_f( void )
|
||||
{
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("USAGE: loadgame <directory>\n");
|
||||
return;
|
||||
}
|
||||
char filename[MAX_QPATH];
|
||||
|
||||
if(sv.state != ss_game) return;
|
||||
|
||||
Msg("Loading game... %s\n", Cmd_Argv(1));
|
||||
SV_ReadSaveFile( Cmd_Argv(1) );
|
||||
strncpy( filename, svs.mapcmd, MAX_QPATH );
|
||||
FS_StripExtension( filename );
|
||||
|
||||
// go to the map
|
||||
sv.state = ss_dead; // don't save current level when changing
|
||||
SV_Map (false, svs.mapcmd, Cmd_Argv(1), true);
|
||||
// just sending console command
|
||||
Cbuf_AddText(va("map %s\n", filename ));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_Savegame_f
|
||||
|
||||
==============
|
||||
*/
|
||||
void SV_Savegame_f (void)
|
||||
{
|
||||
if (sv.state != ss_game)
|
||||
{
|
||||
Msg ("You must be in a game to save.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("USAGE: savegame <directory>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cvar_VariableValue("deathmatch"))
|
||||
{
|
||||
Msg ("Can't savegame in a deathmatch\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcmp (Cmd_Argv(1), "current"))
|
||||
{
|
||||
Msg ("Can't save to 'current'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (maxclients->value == 1 && svs.clients[0].edict->priv.sv->client->ps.stats[STAT_HEALTH] <= 0)
|
||||
{
|
||||
Msg ("\nCan't savegame while dead!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// archive current level, including all client edicts.
|
||||
// when the level is reloaded, they will be shells awaiting
|
||||
// a connecting client
|
||||
SV_WriteSaveFile( Cmd_Argv(1) );
|
||||
|
||||
Msg ("Done.\n");
|
||||
}
|
||||
|
||||
//===============================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Kick_f
|
||||
|
@ -338,28 +334,25 @@ SV_Kick_f
|
|||
Kick a user off of the server
|
||||
==================
|
||||
*/
|
||||
void SV_Kick_f (void)
|
||||
void SV_Kick_f( void )
|
||||
{
|
||||
if (!svs.initialized)
|
||||
{
|
||||
Msg ("No server running.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("Usage: kick <userid>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SV_SetPlayer ()) return;
|
||||
if(!svs.clients)
|
||||
{
|
||||
Msg("^3no server running.\n");
|
||||
return;
|
||||
}
|
||||
if(!SV_SetPlayer()) return;
|
||||
|
||||
SV_BroadcastPrintf (PRINT_HIGH, "%s was kicked\n", sv_client->name);
|
||||
// print directly, because the dropped client won't get the
|
||||
// SV_BroadcastPrintf message
|
||||
SV_ClientPrintf (sv_client, PRINT_HIGH, "You were kicked from the game\n");
|
||||
SV_DropClient (sv_client);
|
||||
sv_client->lastmessage = svs.realtime; // min case there is a funny zombie
|
||||
SV_ClientPrintf(sv_client, PRINT_HIGH, "You were kicked from the game\n");
|
||||
SV_DropClient(sv_client);
|
||||
sv_client->lastmessage = svs.realtime; // min case there is a funny zombie
|
||||
}
|
||||
|
||||
|
||||
|
@ -368,53 +361,49 @@ void SV_Kick_f (void)
|
|||
SV_Status_f
|
||||
================
|
||||
*/
|
||||
void SV_Status_f (void)
|
||||
void SV_Status_f( void )
|
||||
{
|
||||
int i, j, l;
|
||||
int i;
|
||||
client_state_t *cl;
|
||||
char *s;
|
||||
int ping;
|
||||
if (!svs.clients)
|
||||
|
||||
if(!svs.clients)
|
||||
{
|
||||
Msg ("No server running.\n");
|
||||
Msg ("^3no server running.\n");
|
||||
return;
|
||||
}
|
||||
Msg ("map : %s\n", sv.name);
|
||||
|
||||
Msg ("num score ping name lastmsg address qport \n");
|
||||
Msg ("--- ----- ---- --------------- ------- --------------------- ------\n");
|
||||
for (i = 0, cl = svs.clients; i < maxclients->value; i++, cl++)
|
||||
Msg("map: %s\n", sv.name);
|
||||
Msg("num score ping name lastmsg address port \n");
|
||||
Msg("--- ----- ------- --------------- ------- --------------------- ------\n");
|
||||
|
||||
for(i = 0, cl = svs.clients; i < maxclients->integer; i++, cl++)
|
||||
{
|
||||
if (!cl->state) continue;
|
||||
Msg ("%3i ", i);
|
||||
Msg ("%5i ", cl->edict->priv.sv->client->ps.stats[STAT_FRAGS]);
|
||||
int j, l, ping;
|
||||
char *s;
|
||||
|
||||
if (cl->state == cs_connected)
|
||||
Msg ("CNCT ");
|
||||
else if (cl->state == cs_zombie)
|
||||
Msg ("ZMBI ");
|
||||
if (!cl->state) continue;
|
||||
|
||||
Msg("%3i ", i);
|
||||
Msg("%5i ", cl->edict->priv.sv->client->ps.stats[STAT_FRAGS]);
|
||||
|
||||
if (cl->state == cs_connected) Msg("Connect");
|
||||
else if (cl->state == cs_zombie) Msg ("Zombie ");
|
||||
else
|
||||
{
|
||||
ping = cl->ping < 9999 ? cl->ping : 9999;
|
||||
Msg ("%4i ", ping);
|
||||
Msg("%7i ", ping);
|
||||
}
|
||||
|
||||
Msg ("%s", cl->name);
|
||||
l = 16 - strlen(cl->name);
|
||||
for (j=0 ; j<l ; j++)
|
||||
Msg (" ");
|
||||
|
||||
Msg ("%.7f ", svs.realtime - cl->lastmessage );
|
||||
|
||||
Msg("%s", cl->name );
|
||||
l = 16 - std.strlen(cl->name);
|
||||
for (j = 0; j < l; j++) Msg (" ");
|
||||
Msg ("%.5f ", svs.realtime - cl->lastmessage );
|
||||
s = NET_AdrToString ( cl->netchan.remote_address);
|
||||
Msg ("%s", s);
|
||||
l = 22 - strlen(s);
|
||||
for (j=0 ; j<l ; j++)
|
||||
Msg (" ");
|
||||
|
||||
Msg ("%5i", cl->netchan.qport);
|
||||
|
||||
Msg ("\n");
|
||||
for (j = 0; j < l; j++) Msg (" ");
|
||||
Msg("%5i", cl->netchan.qport);
|
||||
Msg("\n");
|
||||
}
|
||||
Msg ("\n");
|
||||
}
|
||||
|
@ -424,36 +413,31 @@ void SV_Status_f (void)
|
|||
SV_ConSay_f
|
||||
==================
|
||||
*/
|
||||
void SV_ConSay_f(void)
|
||||
void SV_ConSay_f( void )
|
||||
{
|
||||
client_state_t *client;
|
||||
int j;
|
||||
char *p;
|
||||
char text[1024];
|
||||
char *p, text[MAX_SYSPATH];
|
||||
client_state_t *client;
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc () < 2)
|
||||
return;
|
||||
if(Cmd_Argc() < 2) return;
|
||||
|
||||
strcpy (text, "console: ");
|
||||
strncpy(text, "console: ", MAX_SYSPATH );
|
||||
p = Cmd_Args();
|
||||
|
||||
if (*p == '"')
|
||||
if(*p == '"')
|
||||
{
|
||||
p++;
|
||||
p[strlen(p)-1] = 0;
|
||||
p[std.strlen(p) - 1] = 0;
|
||||
}
|
||||
std.strncat(text, p, MAX_SYSPATH );
|
||||
|
||||
strcat(text, p);
|
||||
|
||||
for (j = 0, client = svs.clients; j < maxclients->value; j++, client++)
|
||||
for (i = 0, client = svs.clients; i < maxclients->integer; i++, client++)
|
||||
{
|
||||
if (client->state != cs_spawned)
|
||||
continue;
|
||||
SV_ClientPrintf(client, PRINT_CHAT, "%s\n", text);
|
||||
if (client->state != cs_spawned) continue;
|
||||
SV_ClientPrintf(client, PRINT_CHAT, "%s\n", text );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_Heartbeat_f
|
||||
|
@ -464,204 +448,108 @@ void SV_Heartbeat_f (void)
|
|||
svs.last_heartbeat = -99999.0f;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
SV_Serverinfo_f
|
||||
SV_ServerInfo_f
|
||||
|
||||
Examine or change the serverinfo string
|
||||
Examine serverinfo string
|
||||
===========
|
||||
*/
|
||||
void SV_Serverinfo_f (void)
|
||||
void SV_ServerInfo_f( void )
|
||||
{
|
||||
Msg ("Server info settings:\n");
|
||||
Info_Print (Cvar_Serverinfo());
|
||||
Msg("Server info settings:\n");
|
||||
Info_Print( Cvar_Serverinfo());
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===========
|
||||
SV_DumpUser_f
|
||||
SV_ClientInfo_f
|
||||
|
||||
Examine all a users info strings
|
||||
===========
|
||||
*/
|
||||
void SV_DumpUser_f (void)
|
||||
void SV_ClientInfo_f( void )
|
||||
{
|
||||
if (Cmd_Argc() != 2)
|
||||
if(Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("Usage: info <userid>\n");
|
||||
Msg("Usage: clientinfo <userid>\n" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (!SV_SetPlayer ())
|
||||
return;
|
||||
|
||||
Msg ("userinfo\n");
|
||||
Msg ("--------\n");
|
||||
Info_Print (sv_client->userinfo);
|
||||
if(!SV_SetPlayer()) return;
|
||||
Msg("userinfo\n");
|
||||
Msg("--------\n");
|
||||
Info_Print( sv_client->userinfo );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_ServerRecord_f
|
||||
|
||||
Begins server demo recording. Every entity and every message will be
|
||||
recorded, but no playerinfo will be stored. Primarily for demo merging.
|
||||
==============
|
||||
*/
|
||||
void SV_ServerRecord_f (void)
|
||||
{
|
||||
char name[MAX_OSPATH];
|
||||
char buf_data[32768];
|
||||
sizebuf_t buf;
|
||||
int len;
|
||||
int i;
|
||||
|
||||
if (Cmd_Argc() != 2)
|
||||
{
|
||||
Msg ("serverrecord <demoname>\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (svs.demofile)
|
||||
{
|
||||
Msg ("Already recording.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sv.state != ss_game)
|
||||
{
|
||||
Msg ("You must be in a level to record.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// open the demo file
|
||||
sprintf (name, "demos/%s.dm2", Cmd_Argv(1));
|
||||
|
||||
Msg ("recording to %s.\n", name);
|
||||
svs.demofile = FS_Open (name, "wb");
|
||||
if (!svs.demofile)
|
||||
{
|
||||
Msg ("ERROR: couldn't open.\n");
|
||||
return;
|
||||
}
|
||||
|
||||
// setup a buffer to catch all multicasts
|
||||
SZ_Init (&svs.demo_multicast, svs.demo_multicast_buf, sizeof(svs.demo_multicast_buf));
|
||||
|
||||
// write a single giant fake message with all the startup info
|
||||
SZ_Init (&buf, buf_data, sizeof(buf_data));
|
||||
|
||||
// serverdata needs to go over for all types of servers
|
||||
// to make sure the protocol is right, and to set the gamedir
|
||||
|
||||
// send the serverdata
|
||||
MSG_WriteByte (&buf, svc_serverdata);
|
||||
MSG_WriteLong (&buf, PROTOCOL_VERSION);
|
||||
MSG_WriteLong (&buf, svs.spawncount);
|
||||
// 2 means server demo
|
||||
MSG_WriteByte (&buf, 2); // demos are always attract loops
|
||||
MSG_WriteString (&buf, Cvar_VariableString ("gamedir"));
|
||||
MSG_WriteShort (&buf, -1);
|
||||
// send full levelname
|
||||
MSG_WriteString (&buf, sv.configstrings[CS_NAME]);
|
||||
|
||||
for (i=0 ; i<MAX_CONFIGSTRINGS ; i++)
|
||||
{
|
||||
if (sv.configstrings[i][0])
|
||||
{
|
||||
MSG_WriteByte (&buf, svc_configstring);
|
||||
MSG_WriteShort (&buf, i);
|
||||
MSG_WriteString (&buf, sv.configstrings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// write it to the demo file
|
||||
len = LittleLong (buf.cursize);
|
||||
FS_Write (svs.demofile, &len, 4);
|
||||
FS_Write (svs.demofile, buf.data, buf.cursize);
|
||||
|
||||
// the rest of the demo file will be individual frames
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
==============
|
||||
SV_ServerStop_f
|
||||
|
||||
Ends server demo recording
|
||||
==============
|
||||
*/
|
||||
void SV_ServerStop_f (void)
|
||||
{
|
||||
if (!svs.demofile)
|
||||
{
|
||||
Msg ("Not doing a record.\n");
|
||||
return;
|
||||
}
|
||||
FS_Close (svs.demofile);
|
||||
svs.demofile = NULL;
|
||||
Msg ("Completed demo.\n");
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
===============
|
||||
SV_KillServer_f
|
||||
|
||||
Kick everyone off, possibly in preparation for a new game
|
||||
|
||||
===============
|
||||
*/
|
||||
void SV_KillServer_f (void)
|
||||
{
|
||||
if (!svs.initialized) return;
|
||||
SV_Shutdown ("Server was killed.\n", false);
|
||||
NET_Config ( false ); // close network sockets
|
||||
if(!svs.initialized) return;
|
||||
SV_Shutdown("Server was killed.\n", false);
|
||||
NET_Config( false );// close network sockets
|
||||
}
|
||||
|
||||
/*
|
||||
===============
|
||||
SV_ServerCommand_f
|
||||
|
||||
Let the game dll handle a command
|
||||
===============
|
||||
*/
|
||||
void SV_ServerCommand_f (void)
|
||||
{
|
||||
Msg ("No game loaded.\n");
|
||||
}
|
||||
|
||||
//===========================================================
|
||||
|
||||
/*
|
||||
==================
|
||||
SV_InitOperatorCommands
|
||||
==================
|
||||
*/
|
||||
void SV_InitOperatorCommands (void)
|
||||
void SV_InitOperatorCommands( void )
|
||||
{
|
||||
Cmd_AddCommand ("heartbeat", SV_Heartbeat_f);
|
||||
Cmd_AddCommand ("kick", SV_Kick_f);
|
||||
Cmd_AddCommand ("status", SV_Status_f);
|
||||
Cmd_AddCommand ("serverinfo", SV_Serverinfo_f);
|
||||
Cmd_AddCommand ("dumpuser", SV_DumpUser_f);
|
||||
Cmd_AddCommand ("heartbeat", SV_Heartbeat_f, "send a heartbeat to the master server" );
|
||||
Cmd_AddCommand ("kick", SV_Kick_f, "kick a player off the server by number or name" );
|
||||
Cmd_AddCommand ("status", SV_Status_f, "print server status information" );
|
||||
Cmd_AddCommand ("serverinfo", SV_ServerInfo_f, "print server settings" );
|
||||
Cmd_AddCommand ("clientinfo", SV_ClientInfo_f, "print user infostring (player num required)" );
|
||||
|
||||
Cmd_AddCommand ("map", SV_Map_f);
|
||||
Cmd_AddCommand ("demomap", SV_DemoMap_f);
|
||||
Cmd_AddCommand ("gamemap", SV_GameMap_f);
|
||||
Cmd_AddCommand ("setmaster", SV_SetMaster_f);
|
||||
Cmd_AddCommand("map", SV_Map_f, "start new level" );
|
||||
Cmd_AddCommand("demo", SV_Demo_f, "playing a demo file" );
|
||||
Cmd_AddCommand("movie", SV_Movie_f, "playing video file" );
|
||||
Cmd_AddCommand("changelevel", SV_ChangeLevel_f, "changing level" );
|
||||
Cmd_AddCommand("restart", SV_Restart_f, "restarting current level" );
|
||||
|
||||
if ( dedicated->value ) Cmd_AddCommand ("say", SV_ConSay_f);
|
||||
if( dedicated->value )
|
||||
{
|
||||
Cmd_AddCommand ("say", SV_ConSay_f, "send a chat message to everyone on the server" );
|
||||
Cmd_AddCommand("setmaster", SV_SetMaster_f, "set ip address for dedicated server" );
|
||||
}
|
||||
|
||||
Cmd_AddCommand ("serverrecord", SV_ServerRecord_f);
|
||||
Cmd_AddCommand ("serverstop", SV_ServerStop_f);
|
||||
Cmd_AddCommand ("save", SV_Savegame_f);
|
||||
Cmd_AddCommand ("load", SV_Loadgame_f);
|
||||
Cmd_AddCommand ("killserver", SV_KillServer_f);
|
||||
Cmd_AddCommand ("sv", SV_ServerCommand_f);
|
||||
Cmd_AddCommand ("save", SV_Save_f, "save the game to a file");
|
||||
Cmd_AddCommand ("load", SV_Load_f, "load a saved game file" );
|
||||
Cmd_AddCommand ("killserver", SV_KillServer_f, "shutdown current server" );
|
||||
}
|
||||
|
||||
void SV_KillOperatorCommands( void )
|
||||
{
|
||||
Cmd_RemoveCommand("heartbeat");
|
||||
Cmd_RemoveCommand("kick");
|
||||
Cmd_RemoveCommand("status");
|
||||
Cmd_RemoveCommand("serverinfo");
|
||||
Cmd_RemoveCommand("clientinfo");
|
||||
|
||||
Cmd_RemoveCommand("map");
|
||||
Cmd_RemoveCommand("demo");
|
||||
Cmd_RemoveCommand("movie");
|
||||
Cmd_RemoveCommand("changelevel");
|
||||
Cmd_RemoveCommand("restart");
|
||||
|
||||
if( dedicated->value )
|
||||
{
|
||||
Cmd_RemoveCommand("say");
|
||||
Cmd_RemoveCommand("setmaster");
|
||||
}
|
||||
|
||||
Cmd_RemoveCommand("serverrecord");
|
||||
Cmd_RemoveCommand("serverstop");
|
||||
Cmd_RemoveCommand("save");
|
||||
Cmd_RemoveCommand("load");
|
||||
Cmd_RemoveCommand("killserver");
|
||||
}
|
|
@ -125,17 +125,17 @@ void SV_CheckForSavegame (char *savename )
|
|||
{
|
||||
char name[MAX_SYSPATH];
|
||||
|
||||
if (sv_noreload->value) return;
|
||||
if (Cvar_VariableValue ("deathmatch")) return;
|
||||
if (!savename) return;
|
||||
if(sv_noreload->value) return;
|
||||
if(Cvar_VariableValue ("deathmatch")) return;
|
||||
if(!savename) return;
|
||||
|
||||
sprintf (name, "save/%s.bin", savename );
|
||||
sprintf (name, "save/%s", savename );
|
||||
if(!FS_FileExists(name))
|
||||
{
|
||||
Msg("can't find %s\n", savename );
|
||||
return;
|
||||
}
|
||||
SV_ClearWorld ();
|
||||
SV_ClearWorld();
|
||||
|
||||
// get configstrings and areaportals
|
||||
SV_ReadLevelFile ( savename );
|
||||
|
@ -151,24 +151,23 @@ clients along with it.
|
|||
|
||||
================
|
||||
*/
|
||||
void SV_SpawnServer (char *server, char *spawnpoint, char *savename, sv_state_t serverstate, bool attractloop, bool loadgame)
|
||||
void SV_SpawnServer (char *server, char *savename, sv_state_t serverstate )
|
||||
{
|
||||
uint i, checksum;
|
||||
|
||||
if (attractloop) Cvar_Set ("paused", "0");
|
||||
if(serverstate == ss_demo || serverstate == ss_cinematic)
|
||||
Cvar_Set ("paused", "0");
|
||||
|
||||
Msg("SpawnServer [%s]\n", server );
|
||||
if (sv.demofile) FS_Close (sv.demofile);
|
||||
|
||||
svs.spawncount++; // any partially connected client will be restarted
|
||||
sv.state = ss_dead;
|
||||
Host_SetServerState (sv.state);
|
||||
Host_SetServerState(sv.state);
|
||||
|
||||
// wipe the entire per-level structure
|
||||
memset (&sv, 0, sizeof(sv));
|
||||
svs.realtime = 0;
|
||||
sv.loadgame = loadgame;
|
||||
sv.attractloop = attractloop;
|
||||
|
||||
// save name for levels that don't set message
|
||||
strcpy (sv.configstrings[CS_NAME], server);
|
||||
|
@ -183,7 +182,7 @@ void SV_SpawnServer (char *server, char *spawnpoint, char *savename, sv_state_t
|
|||
pm_airaccelerate = 0;
|
||||
}
|
||||
|
||||
SZ_Init (&sv.multicast, sv.multicast_buf, sizeof(sv.multicast_buf));
|
||||
SZ_Init(&sv.multicast, sv.multicast_buf, sizeof(sv.multicast_buf));
|
||||
strcpy (sv.name, server);
|
||||
|
||||
SV_VM_Begin();
|
||||
|
@ -232,7 +231,7 @@ void SV_SpawnServer (char *server, char *spawnpoint, char *savename, sv_state_t
|
|||
Host_SetServerState (sv.state);
|
||||
|
||||
// load and spawn all other entities
|
||||
SV_SpawnEntities ( sv.name, CM_EntityString(), spawnpoint );
|
||||
SV_SpawnEntities ( sv.name, CM_EntityString());
|
||||
|
||||
// run two frames to allow everything to settle
|
||||
SV_RunFrame ();
|
||||
|
@ -341,79 +340,6 @@ void SV_InitGame (void)
|
|||
SV_VM_End();
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
======================
|
||||
SV_Map
|
||||
|
||||
the full syntax is:
|
||||
|
||||
map [*]<map>$<startspot>+<nextserver>
|
||||
|
||||
command from the console or progs.
|
||||
Map can also be a.cin, .pcx, or .dm2 file
|
||||
Nextserver is used to allow a cinematic to play, then proceed to
|
||||
another level:
|
||||
|
||||
map tram.cin+jail_e3
|
||||
======================
|
||||
*/
|
||||
void SV_Map (bool attractloop, char *levelstring, char *savename, bool loadgame)
|
||||
{
|
||||
char *ch;
|
||||
int l;
|
||||
char level[MAX_QPATH], spawnpoint[MAX_QPATH];
|
||||
const char *ext = FS_FileExtension(levelstring);
|
||||
|
||||
sv.loadgame = loadgame;
|
||||
sv.attractloop = attractloop;
|
||||
|
||||
if (sv.state == ss_dead && !sv.loadgame) SV_InitGame ();// the game is just starting
|
||||
|
||||
strcpy (level, levelstring);
|
||||
|
||||
// if there is a + in the map, set nextserver to the remainder
|
||||
ch = strstr(level, "+");
|
||||
if (ch)
|
||||
{
|
||||
*ch = 0;
|
||||
Cvar_Set ("nextserver", va("gamemap \"%s\"", ch + 1));
|
||||
}
|
||||
else Cvar_Set ("nextserver", "");
|
||||
|
||||
// if there is a $, use the remainder as a spawnpoint
|
||||
ch = strstr(level, "$");
|
||||
if (ch)
|
||||
{
|
||||
*ch = 0;
|
||||
strcpy (spawnpoint, ch + 1);
|
||||
}
|
||||
else spawnpoint[0] = 0;
|
||||
|
||||
// skip the end-of-unit flag if necessary
|
||||
if (level[0] == '*') strcpy (level, level+1);
|
||||
|
||||
l = strlen(level);
|
||||
if (!strcmp(ext, "roq"))
|
||||
{
|
||||
SV_BroadcastCommand ("changing\n");
|
||||
SV_SpawnServer (level, spawnpoint, NULL, ss_cinematic, attractloop, loadgame);
|
||||
}
|
||||
else if (!strcmp(ext, "dm2"))
|
||||
{
|
||||
SV_BroadcastCommand ("changing\n");
|
||||
SV_SpawnServer (level, spawnpoint, NULL, ss_demo, attractloop, loadgame);
|
||||
}
|
||||
else
|
||||
{
|
||||
FS_DefaultExtension( level, ".bsp" );
|
||||
SV_BroadcastCommand ("changing\n");
|
||||
SV_SendClientMessages();
|
||||
SV_SpawnServer (level, spawnpoint, savename, ss_game, attractloop, loadgame);
|
||||
}
|
||||
SV_BroadcastCommand ("reconnect\n");
|
||||
}
|
||||
|
||||
void SV_VM_BeginIncreaseEdicts(void)
|
||||
{
|
||||
int i;
|
||||
|
|
|
@ -319,10 +319,10 @@ void SVC_DirectConnect( void )
|
|||
// force the IP key/value pair so the game can filter based on ip
|
||||
Info_SetValueForKey (userinfo, "ip", NET_AdrToString(net_from));
|
||||
|
||||
// attractloop servers are ONLY for local clients
|
||||
if (sv.attractloop)
|
||||
// demo and movie playback servers are ONLY for local clients
|
||||
if(Host_ServerState() == ss_demo || Host_ServerState() == ss_cinematic)
|
||||
{
|
||||
if (!NET_IsLocalAddress (adr))
|
||||
if(!NET_IsLocalAddress (adr))
|
||||
{
|
||||
Msg ("Remote connect in attract loop. Ignored.\n");
|
||||
Netchan_OutOfBandPrint (NS_SERVER, adr, "print\nConnection refused.\n");
|
||||
|
@ -895,13 +895,17 @@ into a more C freindly form.
|
|||
void SV_UserinfoChanged (client_state_t *cl)
|
||||
{
|
||||
char *val;
|
||||
int i;
|
||||
int i;
|
||||
char *cl_name;
|
||||
|
||||
// call prog code to allow overrides
|
||||
SV_ClientUserinfoChanged(cl->edict, cl->userinfo);
|
||||
|
||||
// name for C code
|
||||
strncpy (cl->name, Info_ValueForKey (cl->userinfo, "name"), sizeof(cl->name)-1);
|
||||
cl_name = Info_ValueForKey (cl->userinfo, "name");
|
||||
if(cl_name == "") strncpy (cl->name, "unnamed", sizeof(cl->name) - 1);
|
||||
else strncpy (cl->name, cl_name, sizeof(cl->name) - 1);
|
||||
|
||||
// mask off high bit
|
||||
for (i=0 ; i<sizeof(cl->name) ; i++)
|
||||
cl->name[i] &= 127;
|
||||
|
@ -953,7 +957,7 @@ void SV_Init (void)
|
|||
Cvar_Get ("cheats", "0", CVAR_SERVERINFO|CVAR_LATCH);
|
||||
Cvar_Get ("protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO|CVAR_INIT);
|
||||
maxclients = Cvar_Get ("maxclients", "1", CVAR_SERVERINFO | CVAR_LATCH);
|
||||
hostname = Cvar_Get ("hostname", "noname", CVAR_SERVERINFO | CVAR_ARCHIVE);
|
||||
hostname = Cvar_Get ("hostname", "unnamed", CVAR_SERVERINFO | CVAR_ARCHIVE);
|
||||
timeout = Cvar_Get ("timeout", "125", 0);
|
||||
zombietime = Cvar_Get ("zombietime", "2", 0);
|
||||
sv_showclamp = Cvar_Get ("showclamp", "0", 0);
|
||||
|
|
|
@ -30,9 +30,9 @@ void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
|||
for(var = cvar_vars; var; var = var->next)
|
||||
{
|
||||
if(!(var->flags & CVAR_LATCH)) continue;
|
||||
if (strlen(var->name) >= 64 || strlen(var->string) >= 64)
|
||||
if (std.strlen(var->name) >= 64 || std.strlen(var->string) >= 64)
|
||||
{
|
||||
Msg ("Cvar too long: %s = %s\n", var->name, var->string);
|
||||
MsgDev(D_NOTE, "cvar too long: %s = %s\n", var->name, var->string);
|
||||
continue;
|
||||
}
|
||||
numsavedcvars++;
|
||||
|
@ -40,16 +40,15 @@ void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
|||
|
||||
cvbuffer = (char *)Z_Malloc( numsavedcvars * MAX_QPATH );
|
||||
|
||||
//second pass
|
||||
// second pass
|
||||
for(var = cvar_vars; var; var = var->next)
|
||||
{
|
||||
if(!(var->flags & CVAR_LATCH)) continue;
|
||||
if (strlen(var->name) >= 64 || strlen(var->string) >= 64)
|
||||
{
|
||||
Msg ("Cvar too long: %s = %s\n", var->name, var->string);
|
||||
MsgDev(D_NOTE, "cvar too long: %s = %s\n", var->name, var->string);
|
||||
continue;
|
||||
}
|
||||
|
||||
bufsize = std.strpack(cvbuffer, bufsize, var->name, strlen(var->name));
|
||||
bufsize = std.strpack(cvbuffer, bufsize, var->string, strlen(var->name));
|
||||
}
|
||||
|
@ -60,13 +59,13 @@ void SV_AddCvarLump( dsavehdr_t *hdr, file_t *f )
|
|||
|
||||
void SV_AddCStrLump( dsavehdr_t *hdr, file_t *f )
|
||||
{
|
||||
int i, stringsize, bufsize = 1; //null terminator
|
||||
int i, stringsize, bufsize = 1; // null terminator
|
||||
char *csbuffer = Z_Malloc( MAX_CONFIGSTRINGS * MAX_QPATH );
|
||||
|
||||
//pack the cfg string data
|
||||
// pack the cfg string data
|
||||
for(i = 0; i < MAX_CONFIGSTRINGS; i++)
|
||||
{
|
||||
stringsize = bound(0, strlen(sv.configstrings[i]), MAX_QPATH);
|
||||
stringsize = bound(0, std.strlen(sv.configstrings[i]), MAX_QPATH);
|
||||
bufsize = std.strpack(csbuffer, bufsize, sv.configstrings[i], stringsize );
|
||||
}
|
||||
SV_AddSaveLump( hdr, f, LUMP_CFGSTRING, csbuffer, bufsize );
|
||||
|
@ -79,7 +78,6 @@ void SV_AddCStrLump( dsavehdr_t *hdr, file_t *f )
|
|||
SV_WriteSaveFile
|
||||
=============
|
||||
*/
|
||||
|
||||
void SV_WriteSaveFile( char *name )
|
||||
{
|
||||
char path[MAX_SYSPATH];
|
||||
|
@ -87,18 +85,30 @@ void SV_WriteSaveFile( char *name )
|
|||
dsavehdr_t *header;
|
||||
file_t *savfile;
|
||||
bool autosave = false;
|
||||
|
||||
if(!strcmp(name, "save0")) autosave = true;
|
||||
sprintf (path, "save/%s.bin", name );
|
||||
|
||||
if(sv.state != ss_game) return;
|
||||
if(Cvar_VariableValue("deathmatch"))
|
||||
{
|
||||
MsgDev(D_ERROR, "SV_WriteSaveFile: can't savegame in a deathmatch\n");
|
||||
return;
|
||||
}
|
||||
if(maxclients->value == 1 && svs.clients[0].edict->priv.sv->client->ps.stats[STAT_HEALTH] <= 0)
|
||||
{
|
||||
MsgDev(D_ERROR, "SV_WriteSaveFile: can't savegame while dead!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
if(!std.strcmp(name, "save0.bin")) autosave = true;
|
||||
sprintf (path, "save/%s", name );
|
||||
savfile = FS_Open( path, "wb");
|
||||
|
||||
if (!savfile)
|
||||
{
|
||||
MsgWarn("SV_WriteSaveFile: failed to open %s\n", path );
|
||||
MsgDev(D_ERROR, "SV_WriteSaveFile: failed to open %s\n", path );
|
||||
return;
|
||||
}
|
||||
|
||||
MsgDev (D_INFO, "Saving game... %s\n", name );
|
||||
MsgDev (D_INFO, "Saving game..." );
|
||||
sprintf (comment, "%s - %s", sv.configstrings[CS_NAME], timestamp(TIME_FULL));
|
||||
|
||||
header = (dsavehdr_t *)Z_Malloc( sizeof(dsavehdr_t));
|
||||
|
@ -106,7 +116,7 @@ void SV_WriteSaveFile( char *name )
|
|||
header->version = LittleLong (SAVE_VERSION);
|
||||
FS_Write( savfile, header, sizeof(dsavehdr_t));
|
||||
|
||||
//write lumps
|
||||
// write lumps
|
||||
SV_AddSaveLump( header, savfile, LUMP_COMMENTS, comment, sizeof(comment));
|
||||
SV_AddCStrLump( header, savfile );
|
||||
SV_AddSaveLump( header, savfile, LUMP_AREASTATE, portalopen, sizeof(portalopen));
|
||||
|
@ -115,11 +125,12 @@ void SV_WriteSaveFile( char *name )
|
|||
SV_AddCvarLump( header, savfile );
|
||||
//ge->WriteLump ( header, savfile, LUMP_GAMELOCAL, autosave );
|
||||
|
||||
//merge header
|
||||
// merge header
|
||||
FS_Seek( savfile, 0, SEEK_SET );
|
||||
FS_Write( savfile, header, sizeof(dsavehdr_t));
|
||||
FS_Close( savfile );
|
||||
Z_Free( header );
|
||||
MsgDev(D_INFO, "done.\n");
|
||||
}
|
||||
|
||||
void Sav_LoadComment( lump_t *l )
|
||||
|
@ -205,15 +216,9 @@ void SV_ReadSaveFile( char *name )
|
|||
byte *savfile;
|
||||
int i, id, size;
|
||||
|
||||
sprintf (path, "save/%s.bin", name );
|
||||
sprintf(path, "save/%s", name );
|
||||
savfile = FS_LoadFile(path, &size );
|
||||
|
||||
if(!savfile)
|
||||
{
|
||||
Msg("can't open %s\n", path );
|
||||
return;
|
||||
}
|
||||
|
||||
header = (dsavehdr_t *)savfile;
|
||||
i = LittleLong (header->version);
|
||||
id = LittleLong (header->ident);
|
||||
|
@ -243,7 +248,7 @@ void SV_ReadLevelFile( char *name )
|
|||
byte *savfile;
|
||||
int i, id, size;
|
||||
|
||||
sprintf (path, "save/%s.bin", name );
|
||||
sprintf (path, "save/%s", name );
|
||||
savfile = FS_LoadFile(path, &size );
|
||||
|
||||
if(!savfile)
|
||||
|
@ -293,7 +298,7 @@ bool Menu_ReadComment( char *comment, int savenum )
|
|||
|
||||
sav_base = (byte *)header;
|
||||
Sav_LoadComment(&header->lumps[LUMP_COMMENTS]);
|
||||
strncpy( comment, svs.comment, 32 );
|
||||
std.strncpy( comment, svs.comment, 32 );
|
||||
|
||||
return true;
|
||||
}
|
|
@ -81,7 +81,7 @@ Creates a server's entity / program execution context by
|
|||
parsing textual entity definitions out of an ent file.
|
||||
==============
|
||||
*/
|
||||
void SV_SpawnEntities (char *mapname, char *entities, char *spawnpoint)
|
||||
void SV_SpawnEntities (char *mapname, char *entities)
|
||||
{
|
||||
edict_t *ent;
|
||||
int i;
|
||||
|
|
|
@ -57,7 +57,6 @@ This will be sent on the initial connection and upon each server load.
|
|||
*/
|
||||
void SV_New_f (void)
|
||||
{
|
||||
char *gamedir;
|
||||
int playernum;
|
||||
edict_t *ent;
|
||||
|
||||
|
@ -74,18 +73,12 @@ void SV_New_f (void)
|
|||
return;
|
||||
}
|
||||
|
||||
// serverdata needs to go over for all types of servers
|
||||
// to make sure the protocol is right, and to set the gamedir
|
||||
gamedir = Cvar_VariableString ("gamedir");
|
||||
|
||||
// send the serverdata
|
||||
MSG_WriteByte (&sv_client->netchan.message, svc_serverdata);
|
||||
MSG_WriteLong (&sv_client->netchan.message, PROTOCOL_VERSION);
|
||||
MSG_WriteLong (&sv_client->netchan.message, svs.spawncount);
|
||||
MSG_WriteByte (&sv_client->netchan.message, sv.attractloop);
|
||||
MSG_WriteString (&sv_client->netchan.message, gamedir);
|
||||
|
||||
if (sv.state == ss_cinematic) playernum = -1;
|
||||
if(sv.state == ss_cinematic) playernum = -1;
|
||||
else playernum = sv_client - svs.clients;
|
||||
MSG_WriteShort (&sv_client->netchan.message, playernum );
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ void S_Init( void )
|
|||
cv = Cvar_Get ("s_initsound", "1", 0);
|
||||
if ( !cv->value ) return;
|
||||
|
||||
Cmd_AddCommand("play", S_Play_f);
|
||||
Cmd_AddCommand("music", S_Music_f);
|
||||
Cmd_AddCommand("s_list", S_SoundList_f);
|
||||
Cmd_AddCommand("s_info", S_SoundInfo_f);
|
||||
Cmd_AddCommand("s_stop", S_StopAllSounds);
|
||||
Cmd_AddCommand("play", S_Play_f, "playing a specified sound file" );
|
||||
Cmd_AddCommand("music", S_Music_f, "starting a background track" );
|
||||
Cmd_AddCommand("snd_list", S_SoundList_f, "display loaded sounds" );
|
||||
Cmd_AddCommand("snd_info", S_SoundInfo_f, "print sound system information" );
|
||||
Cmd_AddCommand("snd_stop", S_StopAllSounds, "stop all sounds" );
|
||||
|
||||
if (SNDDMA_Init())
|
||||
{
|
||||
|
|
|
@ -34,7 +34,6 @@ static dllfunc_t dsound_funcs[] =
|
|||
dll_info_t dsound_dll = { "dsound.dll", dsound_funcs, NULL, NULL, NULL, false, 0 };
|
||||
|
||||
#define SECONDARY_BUFFER_SIZE 0x10000
|
||||
extern HWND cl_hwnd;
|
||||
static bool dsound_init;
|
||||
static int sample16;
|
||||
static dword gSndBufSize;
|
||||
|
@ -79,7 +78,7 @@ void SNDDMA_Shutdown( void )
|
|||
if ( pDS )
|
||||
{
|
||||
MsgDev(D_INFO, "...setting NORMAL coop level\n" );
|
||||
pDS->lpVtbl->SetCooperativeLevel( pDS, cl_hwnd, DSSCL_PRIORITY );
|
||||
pDS->lpVtbl->SetCooperativeLevel( pDS, host.hWnd, DSSCL_PRIORITY );
|
||||
}
|
||||
|
||||
if ( pDSBuf )
|
||||
|
@ -137,7 +136,7 @@ int SNDDMA_InitDS( void )
|
|||
MsgDev(D_INFO, "ok\n" );
|
||||
|
||||
MsgDev(D_INFO, "...setting DSSCL_PRIORITY coop level: " );
|
||||
if(DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, cl_hwnd, DSSCL_PRIORITY ))
|
||||
if(DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, host.hWnd, DSSCL_PRIORITY ))
|
||||
{
|
||||
MsgDev(D_INFO, "failed\n");
|
||||
SNDDMA_Shutdown ();
|
||||
|
@ -337,7 +336,7 @@ void SNDDMA_Activate( void )
|
|||
{
|
||||
if( !pDS ) return;
|
||||
|
||||
if( DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, cl_hwnd, DSSCL_PRIORITY ))
|
||||
if( DS_OK != pDS->lpVtbl->SetCooperativeLevel( pDS, host.hWnd, DSSCL_PRIORITY ))
|
||||
{
|
||||
MsgDev(D_INFO, "sound SetCooperativeLevel failed\n");
|
||||
SNDDMA_Shutdown();
|
||||
|
|
572
engine/vid_dll.c
572
engine/vid_dll.c
|
@ -1,572 +0,0 @@
|
|||
/*
|
||||
Copyright (C) 1997-2001 Id Software, Inc.
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
See the GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
*/
|
||||
// Main windowed and fullscreen graphics interface module. This module
|
||||
// is used for both the software and OpenGL rendering versions of the
|
||||
// Quake refresh engine.
|
||||
#include "engine.h"
|
||||
#include "client.h"
|
||||
|
||||
// Structure containing functions exported from refresh DLL
|
||||
render_exp_t *re;
|
||||
|
||||
extern HWND cl_hwnd;
|
||||
extern bool ActiveApp, Minimized;
|
||||
extern HINSTANCE global_hInstance;
|
||||
|
||||
#ifndef WM_MOUSEWHEEL
|
||||
#define WM_MOUSEWHEEL (WM_MOUSELAST+1) // message that will be supported by the OS
|
||||
#endif
|
||||
|
||||
static UINT MSH_MOUSEWHEEL;
|
||||
|
||||
// Console variables that we need to access from this module
|
||||
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;
|
||||
|
||||
// Global variables used internally by this module
|
||||
viddef_t viddef; // global video state; used by other modules
|
||||
dll_info_t render_dll = { "render.dll", NULL, "CreateAPI", NULL, NULL, true, sizeof(render_exp_t) };
|
||||
bool reflib_active = 0;
|
||||
|
||||
HWND cl_hwnd; // Main window handle for life of program
|
||||
|
||||
#define VID_NUM_MODES ( sizeof( vid_modes ) / sizeof( vid_modes[0] ) )
|
||||
|
||||
LONG WINAPI MainWndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
||||
/*
|
||||
==========================================================================
|
||||
|
||||
DLL GLUE
|
||||
|
||||
==========================================================================
|
||||
*/
|
||||
//==========================================================================
|
||||
|
||||
static byte s_scantokey[128] =
|
||||
{
|
||||
|
||||
// 0 1 2 3 4 5 6 7
|
||||
// 8 9 A B C D E F
|
||||
0 , 27, '1', '2', '3', '4', '5', '6',
|
||||
'7', '8', '9', '0', '-', '=', K_BACKSPACE, 9, // 0
|
||||
'q', 'w', 'e', 'r', 't', 'y', 'u', 'i',
|
||||
'o', 'p', '[', ']', 13 , K_CTRL,'a', 's', // 1
|
||||
'd', 'f', 'g', 'h', 'j', 'k', 'l', ';',
|
||||
'\'' , '`', K_SHIFT,'\\', 'z', 'x', 'c', 'v', // 2
|
||||
'b', 'n', 'm', ',', '.', '/', K_SHIFT,'*',
|
||||
K_ALT,' ', K_CAPSLOCK , K_F1, K_F2, K_F3, K_F4, K_F5, // 3
|
||||
K_F6, K_F7, K_F8, K_F9, K_F10, K_PAUSE, 0 , K_HOME,
|
||||
K_UPARROW,K_PGUP,K_KP_MINUS,K_LEFTARROW,K_KP_5,K_RIGHTARROW, K_KP_PLUS,K_END, //4
|
||||
K_DOWNARROW,K_PGDN,K_INS,K_DEL,0,0, 0, K_F11,
|
||||
K_F12,0 , 0 , 0 , 0 , 0 , 0 , 0, // 5
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0, // 6
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0,
|
||||
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 // 7
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
=======
|
||||
MapKey
|
||||
|
||||
Map from windows to quake keynums
|
||||
=======
|
||||
*/
|
||||
static int MapKey (int key)
|
||||
{
|
||||
int result;
|
||||
int modified;
|
||||
bool is_extended;
|
||||
|
||||
// Com_Printf( "0x%x\n", key);
|
||||
|
||||
modified = ( key >> 16 ) & 255;
|
||||
|
||||
if ( modified > 127 )
|
||||
return 0;
|
||||
|
||||
if ( key & ( 1 << 24 ) )
|
||||
{
|
||||
is_extended = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_extended = false;
|
||||
}
|
||||
|
||||
result = s_scantokey[modified];
|
||||
|
||||
if ( !is_extended )
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case K_HOME:
|
||||
return K_KP_HOME;
|
||||
case K_UPARROW:
|
||||
return K_KP_UPARROW;
|
||||
case K_PGUP:
|
||||
return K_KP_PGUP;
|
||||
case K_LEFTARROW:
|
||||
return K_KP_LEFTARROW;
|
||||
case K_RIGHTARROW:
|
||||
return K_KP_RIGHTARROW;
|
||||
case K_END:
|
||||
return K_KP_END;
|
||||
case K_DOWNARROW:
|
||||
return K_KP_DOWNARROW;
|
||||
case K_PGDN:
|
||||
return K_KP_PGDN;
|
||||
case K_INS:
|
||||
return K_KP_INS;
|
||||
case K_DEL:
|
||||
return K_KP_DEL;
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
switch ( result )
|
||||
{
|
||||
case K_PAUSE:
|
||||
return K_KP_NUMLOCK;
|
||||
case 0x0D:
|
||||
return K_KP_ENTER;
|
||||
case 0x2F:
|
||||
return K_KP_SLASH;
|
||||
case 0xAF:
|
||||
return K_KP_PLUS;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
void AppActivate(BOOL fActive, BOOL minimize)
|
||||
{
|
||||
Minimized = minimize;
|
||||
|
||||
Key_ClearStates();
|
||||
|
||||
// we don't want to act like we're active if we're minimized
|
||||
if (fActive && !Minimized)
|
||||
ActiveApp = true;
|
||||
else
|
||||
ActiveApp = false;
|
||||
|
||||
// minimize/restore mouse-capture on demand
|
||||
if (!ActiveApp)
|
||||
{
|
||||
IN_Activate (false);
|
||||
}
|
||||
else
|
||||
{
|
||||
IN_Activate (true);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
MainWndProc
|
||||
|
||||
main window procedure
|
||||
====================
|
||||
*/
|
||||
LONG WINAPI MainWndProc ( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
LONG lRet = 0;
|
||||
|
||||
if ( uMsg == MSH_MOUSEWHEEL )
|
||||
{
|
||||
if ( ( ( int ) wParam ) > 0 )
|
||||
{
|
||||
Key_Event( K_MWHEELUP, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELUP, false, host.sv_timer );
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Event( K_MWHEELDOWN, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELDOWN, false, host.sv_timer );
|
||||
}
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
switch (uMsg)
|
||||
{
|
||||
case WM_MOUSEWHEEL:
|
||||
/*
|
||||
** this chunk of code theoretically only works under NT4 and Win98
|
||||
** since this message doesn't exist under Win95
|
||||
*/
|
||||
if ( ( short ) HIWORD( wParam ) > 0 )
|
||||
{
|
||||
Key_Event( K_MWHEELUP, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELUP, false, host.sv_timer );
|
||||
}
|
||||
else
|
||||
{
|
||||
Key_Event( K_MWHEELDOWN, true, host.sv_timer );
|
||||
Key_Event( K_MWHEELDOWN, false, host.sv_timer );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_HOTKEY:
|
||||
return 0;
|
||||
|
||||
case WM_CREATE:
|
||||
cl_hwnd = hWnd;
|
||||
|
||||
MSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG");
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
|
||||
case WM_PAINT:
|
||||
SCR_FillRect(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT, g_color_table[0]);
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
case WM_DESTROY:
|
||||
// let sound and input know about this?
|
||||
cl_hwnd = NULL;
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
case WM_ACTIVATE:
|
||||
{
|
||||
int fActive, fMinimized;
|
||||
|
||||
// KJB: Watch this for problems in fullscreen modes with Alt-tabbing.
|
||||
fActive = LOWORD(wParam);
|
||||
fMinimized = (BOOL) HIWORD(wParam);
|
||||
|
||||
AppActivate( fActive != WA_INACTIVE, fMinimized);
|
||||
SNDDMA_Activate();
|
||||
if ( reflib_active ) re->AppActivate( !( fActive == WA_INACTIVE ) );
|
||||
}
|
||||
break;
|
||||
case WM_MOVE:
|
||||
{
|
||||
int xPos, yPos;
|
||||
RECT r;
|
||||
int style;
|
||||
|
||||
if (!vid_fullscreen->value)
|
||||
{
|
||||
xPos = (short) LOWORD(lParam); // horizontal position
|
||||
yPos = (short) HIWORD(lParam); // vertical position
|
||||
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = 1;
|
||||
r.bottom = 1;
|
||||
|
||||
style = GetWindowLong( hWnd, GWL_STYLE );
|
||||
AdjustWindowRect( &r, style, FALSE );
|
||||
|
||||
Cvar_SetValue( "vid_xpos", xPos + r.left);
|
||||
Cvar_SetValue( "vid_ypos", yPos + r.top);
|
||||
vid_xpos->modified = false;
|
||||
vid_ypos->modified = false;
|
||||
if (ActiveApp) IN_Activate (true);
|
||||
}
|
||||
}
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
// this is complicated because Win32 seems to pack multiple mouse events into
|
||||
// one update sometimes, so we always check all states and look for events
|
||||
case WM_LBUTTONDOWN:
|
||||
case WM_LBUTTONUP:
|
||||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MBUTTONDOWN:
|
||||
case WM_MBUTTONUP:
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
int temp;
|
||||
|
||||
temp = 0;
|
||||
|
||||
if (wParam & MK_LBUTTON)
|
||||
temp |= 1;
|
||||
|
||||
if (wParam & MK_RBUTTON)
|
||||
temp |= 2;
|
||||
|
||||
if (wParam & MK_MBUTTON)
|
||||
temp |= 4;
|
||||
|
||||
IN_MouseEvent (temp);
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_SYSCOMMAND:
|
||||
if ( wParam == SC_SCREENSAVE ) return 0;
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
case WM_SYSKEYDOWN:
|
||||
if ( wParam == 13 )
|
||||
{
|
||||
if ( vid_fullscreen )
|
||||
{
|
||||
Cvar_SetValue( "vid_fullscreen", !vid_fullscreen->value );
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
// fall through
|
||||
case WM_KEYDOWN:
|
||||
Key_Event( MapKey( lParam ), true, host.sv_timer);
|
||||
break;
|
||||
case WM_SYSKEYUP:
|
||||
case WM_KEYUP:
|
||||
Key_Event( MapKey( lParam ), false, host.sv_timer);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
CL_CharEvent( wParam );
|
||||
break;
|
||||
default: // pass all unhandled messages to DefWindowProc
|
||||
return DefWindowProc (hWnd, uMsg, wParam, lParam);
|
||||
}
|
||||
|
||||
// return 0 if handled message, 1 if not
|
||||
return DefWindowProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_Restart_f
|
||||
|
||||
Console command to re-start the video mode and refresh DLL. We do this
|
||||
simply by setting the modified flag for the vid_ref variable, which will
|
||||
cause the entire video mode and refresh DLL to be reset on the next frame.
|
||||
============
|
||||
*/
|
||||
void VID_Restart_f (void)
|
||||
{
|
||||
vid_ref->modified = true;
|
||||
}
|
||||
|
||||
void VID_Front_f( void )
|
||||
{
|
||||
SetWindowLong( cl_hwnd, GWL_EXSTYLE, WS_EX_TOPMOST );
|
||||
SetForegroundWindow( cl_hwnd );
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_GetModeInfo
|
||||
*/
|
||||
typedef struct vidmode_s
|
||||
{
|
||||
const char *description;
|
||||
int width, height;
|
||||
int mode;
|
||||
} vidmode_t;
|
||||
|
||||
vidmode_t vid_modes[] =
|
||||
{
|
||||
{ "Mode 0: 640x480", 640, 480, 1 },
|
||||
{ "Mode 1: 800x600", 800, 600, 2 },
|
||||
{ "Mode 2: 1024x768", 1024, 768, 3 },
|
||||
{ "Mode 3: 1280x960", 1280, 960, 4 },
|
||||
{ "Mode 4: 1280x1024", 1280, 1024, 5 },
|
||||
{ "Mode 5: 1600x1200", 1600, 1200, 6 },
|
||||
{ "Mode 6: 2048x1536", 2048, 1536, 7 }
|
||||
};
|
||||
|
||||
bool VID_GetModeInfo( int *width, int *height, int mode )
|
||||
{
|
||||
if ( mode < 0 || mode >= VID_NUM_MODES )
|
||||
return false;
|
||||
|
||||
*width = vid_modes[mode].width;
|
||||
*height = vid_modes[mode].height;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_UpdateWindowPosAndSize
|
||||
*/
|
||||
void VID_UpdateWindowPosAndSize( int x, int y )
|
||||
{
|
||||
RECT r;
|
||||
int style;
|
||||
int w, h;
|
||||
|
||||
r.left = 0;
|
||||
r.top = 0;
|
||||
r.right = viddef.width;
|
||||
r.bottom = viddef.height;
|
||||
|
||||
style = GetWindowLong( cl_hwnd, GWL_STYLE );
|
||||
AdjustWindowRect( &r, style, FALSE );
|
||||
|
||||
w = r.right - r.left;
|
||||
h = r.bottom - r.top;
|
||||
|
||||
MoveWindow( cl_hwnd, vid_xpos->value, vid_ypos->value, w, h, TRUE );
|
||||
}
|
||||
|
||||
/*
|
||||
** VID_NewWindow
|
||||
*/
|
||||
void VID_NewWindow ( int width, int height)
|
||||
{
|
||||
viddef.width = width;
|
||||
viddef.height = height;
|
||||
|
||||
cl.force_refdef = true; // can't use a paused refdef
|
||||
}
|
||||
|
||||
void VID_FreeReflib (void)
|
||||
{
|
||||
Sys_FreeLibrary( &render_dll );
|
||||
|
||||
memset (&re, 0, sizeof(re));
|
||||
reflib_active = false;
|
||||
}
|
||||
|
||||
cvar_t *VID_Cvar_Get(const char *var_name, const char *value, int flags)
|
||||
{
|
||||
return _Cvar_Get(var_name, value, flags, "render variable" );
|
||||
}
|
||||
|
||||
void VID_Cmd_AddCommand(const char *cmd_name, xcommand_t function)
|
||||
{
|
||||
_Cmd_AddCommand(cmd_name, function, "render command" );
|
||||
}
|
||||
|
||||
/*
|
||||
==============
|
||||
VID_InitRender
|
||||
==============
|
||||
*/
|
||||
void VID_InitRender( void )
|
||||
{
|
||||
static render_imp_t ri;
|
||||
stdlib_api_t io = Host_GetStdio( false );
|
||||
launch_t CreateRender;
|
||||
|
||||
VID_FreeRender();
|
||||
|
||||
ri.api_size = sizeof(render_imp_t);
|
||||
|
||||
ri.Cmd_AddCommand = VID_Cmd_AddCommand;
|
||||
ri.Cmd_RemoveCommand = Cmd_RemoveCommand;
|
||||
ri.Cmd_Argc = Cmd_Argc;
|
||||
ri.Cmd_Argv = Cmd_Argv;
|
||||
ri.Cmd_ExecuteText = Cbuf_ExecuteText;
|
||||
|
||||
// studio callbacks
|
||||
ri.StudioEvent = CL_StudioEvent;
|
||||
ri.ShowCollision = Phys->ShowCollision;
|
||||
|
||||
ri.Cvar_Get = VID_Cvar_Get;
|
||||
ri.Cvar_Set = Cvar_Set;
|
||||
ri.Cvar_SetValue = Cvar_SetValue;
|
||||
|
||||
ri.Vid_GetModeInfo = VID_GetModeInfo;
|
||||
ri.Vid_MenuInit = VID_MenuInit;
|
||||
ri.Vid_NewWindow = VID_NewWindow;
|
||||
|
||||
Sys_LoadLibrary( &render_dll );
|
||||
|
||||
CreateRender = (void *)render_dll.main;
|
||||
re = CreateRender( &io, &ri );
|
||||
|
||||
if(!re->Init( global_hInstance, MainWndProc ))
|
||||
Sys_Error("VID_InitRender: can't init render.dll\nUpdate your opengl drivers\n");
|
||||
|
||||
reflib_active = true;
|
||||
CL_Snd_Restart_f();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_CheckChanges
|
||||
|
||||
This function gets called once just before drawing each frame, and it's sole purpose in life
|
||||
is to check to see if any of the video mode parameters have changed, and if they have to
|
||||
update the rendering DLL and/or video mode to match.
|
||||
============
|
||||
*/
|
||||
void VID_CheckChanges (void)
|
||||
{
|
||||
if( vid_ref->modified )
|
||||
{
|
||||
cl.force_refdef = true; // can't use a paused refdef
|
||||
S_StopAllSounds();
|
||||
}
|
||||
while(vid_ref->modified)
|
||||
{
|
||||
/*
|
||||
** refresh has changed
|
||||
*/
|
||||
vid_ref->modified = false;
|
||||
vid_fullscreen->modified = true;
|
||||
cl.refresh_prepped = false;
|
||||
VID_InitRender();
|
||||
}
|
||||
|
||||
// update our window position
|
||||
if ( vid_xpos->modified || vid_ypos->modified )
|
||||
{
|
||||
if (!vid_fullscreen->value)
|
||||
VID_UpdateWindowPosAndSize( vid_xpos->value, vid_ypos->value );
|
||||
|
||||
vid_xpos->modified = false;
|
||||
vid_ypos->modified = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_Init
|
||||
============
|
||||
*/
|
||||
void VID_Init (void)
|
||||
{
|
||||
/* Create the video variables so we know how to start the graphics drivers */
|
||||
vid_ref = Cvar_Get ("vid_ref", "gl", 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 );
|
||||
|
||||
/* Add some console commands that we want to handle */
|
||||
Cmd_AddCommand ("vid_restart", VID_Restart_f);
|
||||
Cmd_AddCommand ("vid_front", VID_Front_f);
|
||||
|
||||
// Start the graphics mode and load refresh DLL
|
||||
VID_CheckChanges();
|
||||
}
|
||||
|
||||
/*
|
||||
============
|
||||
VID_FreeRender
|
||||
============
|
||||
*/
|
||||
void VID_FreeRender (void)
|
||||
{
|
||||
if ( reflib_active )
|
||||
{
|
||||
re->Shutdown();
|
||||
VID_FreeReflib ();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -20,7 +20,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#include "client.h"
|
||||
#include "qmenu.h"
|
||||
|
||||
extern cvar_t *vid_fullscreen;
|
||||
extern cvar_t *r_fullscreen;
|
||||
extern cvar_t *vid_gamma;
|
||||
|
||||
static cvar_t *gl_mode;
|
||||
|
@ -70,14 +70,12 @@ static void ResetDefaults( void *unused )
|
|||
|
||||
static void ApplyChanges( void *unused )
|
||||
{
|
||||
extern cvar_t *vid_ref;
|
||||
|
||||
Cvar_SetValue( "gl_picmip", 3 - s_tq_slider.curvalue );
|
||||
Cvar_SetValue( "vid_fullscreen", s_fs_box.curvalue );
|
||||
Cvar_SetValue( "r_fullscreen", s_fs_box.curvalue );
|
||||
Cvar_SetValue( "gl_ext_palettedtexture", s_paletted_texture_box.curvalue );
|
||||
Cvar_SetValue( "gl_finish", s_finish_box.curvalue );
|
||||
Cvar_SetValue( "gl_mode", s_mode_list.curvalue );
|
||||
vid_ref->modified = true;
|
||||
Cbuf_AddText("vid_restart\n"); // restart render
|
||||
|
||||
M_ForceMenuOff();
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ void VID_MenuInit( void )
|
|||
s_fs_box.generic.y = 20;
|
||||
s_fs_box.generic.name = "fullscreen";
|
||||
s_fs_box.itemnames = yesno_names;
|
||||
s_fs_box.curvalue = vid_fullscreen->value;
|
||||
s_fs_box.curvalue = r_fullscreen->value;
|
||||
|
||||
s_tq_slider.generic.type = MTYPE_SLIDER;
|
||||
s_tq_slider.generic.x = 0;
|
||||
|
|
|
@ -120,17 +120,19 @@ char com_tolower(const char in )
|
|||
return out;
|
||||
}
|
||||
|
||||
size_t com_strncat(char *dst, const char *src, size_t siz)
|
||||
size_t com_strncat(char *dst, const char *src, size_t size)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
register size_t n = size;
|
||||
size_t dlen;
|
||||
|
||||
// Find the end of dst and adjust bytes left but don't go past end
|
||||
while (n-- != 0 && *d != '\0') d++;
|
||||
if(!dst || !src || !size) return 0;
|
||||
|
||||
// find the end of dst and adjust bytes left but don't go past end
|
||||
while(n-- != 0 && *d != '\0') d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
n = size - dlen;
|
||||
|
||||
if (n == 0) return(dlen + com_strlen(s));
|
||||
while (*s != '\0')
|
||||
|
@ -144,7 +146,7 @@ size_t com_strncat(char *dst, const char *src, size_t siz)
|
|||
}
|
||||
|
||||
*d = '\0';
|
||||
return(dlen + (s - src)); //count does not include NUL
|
||||
return(dlen + (s - src)); // count does not include NULL
|
||||
}
|
||||
|
||||
size_t com_strcat(char *dst, const char *src )
|
||||
|
@ -152,13 +154,15 @@ size_t com_strcat(char *dst, const char *src )
|
|||
return com_strncat( dst, src, 99999 );
|
||||
}
|
||||
|
||||
size_t com_strncpy(char *dst, const char *src, size_t siz)
|
||||
size_t com_strncpy(char *dst, const char *src, size_t size)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
register size_t n = size;
|
||||
|
||||
// Copy as many bytes as will fit
|
||||
if(!dst || !src || !size) return 0;
|
||||
|
||||
// copy as many bytes as will fit
|
||||
if (n != 0 && --n != 0)
|
||||
{
|
||||
do
|
||||
|
@ -168,10 +172,10 @@ size_t com_strncpy(char *dst, const char *src, size_t siz)
|
|||
} while (--n != 0);
|
||||
}
|
||||
|
||||
// Not enough room in dst, add NULL and traverse rest of src
|
||||
// not enough room in dst, add NULL and traverse rest of src
|
||||
if (n == 0)
|
||||
{
|
||||
if (siz != 0) *d = '\0'; //NULL-terminate dst
|
||||
if (size != 0) *d = '\0'; // NULL-terminate dst
|
||||
while (*s++);
|
||||
}
|
||||
return(s - src - 1); // count does not include NULL
|
||||
|
@ -186,6 +190,8 @@ char *com_stralloc(const char *s, const char *filename, int fileline)
|
|||
{
|
||||
char *b;
|
||||
|
||||
if(!s) return NULL;
|
||||
|
||||
b = _mem_alloc(Sys.stringpool, com_strlen(s) + 1, filename, fileline );
|
||||
com_strcpy(b, s);
|
||||
|
||||
|
|
|
@ -714,8 +714,8 @@ typedef struct render_imp_s
|
|||
// interface validator
|
||||
size_t api_size; // must matched with sizeof(render_imp_t)
|
||||
|
||||
void (*Cmd_AddCommand) (char *name, void(*cmd)(void));
|
||||
void (*Cmd_RemoveCommand) (char *name);
|
||||
void (*Cmd_AddCommand)( const char *name, xcommand_t cmd, const char *cmd_desc );
|
||||
void (*Cmd_RemoveCommand)( char *name );
|
||||
int (*Cmd_Argc) (void);
|
||||
char *(*Cmd_Argv) (int i);
|
||||
void (*Cmd_ExecuteText) (int exec_when, char *text);
|
||||
|
@ -724,9 +724,9 @@ typedef struct render_imp_s
|
|||
void (*StudioEvent)( mstudioevent_t *event, entity_t *ent );
|
||||
void (*ShowCollision)( void );// debug
|
||||
|
||||
cvar_t *(*Cvar_Get) (char *name, char *value, int flags);
|
||||
void (*Cvar_Set)( char *name, char *value );
|
||||
void (*Cvar_SetValue)( char *name, float value );
|
||||
cvar_t *(*Cvar_Get)( const char *name, const char *value, int flags, const char *desc );
|
||||
void (*Cvar_Set)( const char *name, const char *value );
|
||||
void (*Cvar_SetValue)( const char *name, float value );
|
||||
|
||||
bool (*Vid_GetModeInfo)( int *width, int *height, int mode );
|
||||
void (*Vid_MenuInit)( void );
|
||||
|
|
|
@ -62,6 +62,9 @@ void R_ConcatTransforms (float in1[3][4], float in2[3][4], float out[3][4]);
|
|||
#define MsgWarn std.wprintf
|
||||
#define Sys_Error std.error
|
||||
|
||||
#define Cvar_Get(name, value, flags) ri.Cvar_Get(name, value, flags, "render variable" )
|
||||
#define Cmd_AddCommand(name, cmd) ri.Cmd_AddCommand(name, cmd, "render command" )
|
||||
|
||||
#ifndef __VIDDEF_T
|
||||
#define __VIDDEF_T
|
||||
typedef struct
|
||||
|
@ -287,7 +290,7 @@ extern cvar_t *gl_texturesolidmode;
|
|||
extern cvar_t *gl_saturatelighting;
|
||||
extern cvar_t *gl_lockpvs;
|
||||
|
||||
extern cvar_t *vid_fullscreen;
|
||||
extern cvar_t *r_fullscreen;
|
||||
extern cvar_t *vid_gamma;
|
||||
|
||||
extern cvar_t *intensity;
|
||||
|
|
|
@ -952,7 +952,7 @@ void R_BeginRegistration (char *model)
|
|||
|
||||
// explicitly free the old map if different
|
||||
// this guarantees that mod_known[0] is the world map
|
||||
flushmap = ri.Cvar_Get ("flushmap", "0", 0);
|
||||
flushmap = Cvar_Get ("flushmap", "0", 0);
|
||||
if(strcmp(mod_known[0].name, fullname) || flushmap->value)
|
||||
{
|
||||
Mod_Free (&mod_known[0]);
|
||||
|
|
|
@ -157,7 +157,7 @@ cvar_t *r_bloom_fast_sample;
|
|||
|
||||
cvar_t *gl_3dlabs_broken;
|
||||
|
||||
cvar_t *vid_fullscreen;
|
||||
cvar_t *r_fullscreen;
|
||||
cvar_t *vid_gamma;
|
||||
cvar_t *r_pause;
|
||||
|
||||
|
@ -916,93 +916,93 @@ void R_RenderFrame (refdef_t *fd)
|
|||
|
||||
void R_Register( void )
|
||||
{
|
||||
r_lefthand = ri.Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
r_norefresh = ri.Cvar_Get ("r_norefresh", "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_novis = ri.Cvar_Get ("r_novis", "0", 0);
|
||||
r_nocull = ri.Cvar_Get ("r_nocull", "0", 0);
|
||||
r_lerpmodels = ri.Cvar_Get ("r_lerpmodels", "1", 0);
|
||||
r_speeds = ri.Cvar_Get ("r_speeds", "0", 0);
|
||||
r_pause = ri.Cvar_Get("paused", "0", 0);
|
||||
r_lefthand = Cvar_Get( "hand", "0", CVAR_USERINFO | CVAR_ARCHIVE );
|
||||
r_norefresh = Cvar_Get ("r_norefresh", "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_novis = Cvar_Get ("r_novis", "0", 0);
|
||||
r_nocull = Cvar_Get ("r_nocull", "0", 0);
|
||||
r_lerpmodels = Cvar_Get ("r_lerpmodels", "1", 0);
|
||||
r_speeds = Cvar_Get ("r_speeds", "0", 0);
|
||||
r_pause = Cvar_Get("paused", "0", 0);
|
||||
|
||||
r_loading = ri.Cvar_Get("scr_loading", "0", 0 );
|
||||
r_loading = Cvar_Get("scr_loading", "0", 0 );
|
||||
|
||||
r_lightlevel = ri.Cvar_Get ("r_lightlevel", "0", 0);
|
||||
r_emboss_bump = ri.Cvar_Get ("r_emboss_bump", "0", 0);
|
||||
r_lightlevel = Cvar_Get ("r_lightlevel", "0", 0);
|
||||
r_emboss_bump = Cvar_Get ("r_emboss_bump", "0", 0);
|
||||
|
||||
r_motionblur_intens = ri.Cvar_Get( "r_motionblur_intens", "0.65", CVAR_ARCHIVE );
|
||||
r_motionblur = ri.Cvar_Get( "r_motionblur", "0", CVAR_ARCHIVE );
|
||||
r_motionblur_intens = Cvar_Get( "r_motionblur_intens", "0.65", CVAR_ARCHIVE );
|
||||
r_motionblur = Cvar_Get( "r_motionblur", "0", CVAR_ARCHIVE );
|
||||
|
||||
gl_nosubimage = ri.Cvar_Get( "gl_nosubimage", "0", 0 );
|
||||
gl_allow_software = ri.Cvar_Get( "gl_allow_software", "0", 0 );
|
||||
gl_nosubimage = Cvar_Get( "gl_nosubimage", "0", 0 );
|
||||
gl_allow_software = Cvar_Get( "gl_allow_software", "0", 0 );
|
||||
|
||||
gl_particle_min_size = ri.Cvar_Get( "gl_particle_min_size", "2", CVAR_ARCHIVE );
|
||||
gl_particle_max_size = ri.Cvar_Get( "gl_particle_max_size", "40", CVAR_ARCHIVE );
|
||||
gl_particle_size = ri.Cvar_Get( "gl_particle_size", "40", CVAR_ARCHIVE );
|
||||
gl_particle_att_a = ri.Cvar_Get( "gl_particle_att_a", "0.01", CVAR_ARCHIVE );
|
||||
gl_particle_att_b = ri.Cvar_Get( "gl_particle_att_b", "0.0", CVAR_ARCHIVE );
|
||||
gl_particle_att_c = ri.Cvar_Get( "gl_particle_att_c", "0.01", CVAR_ARCHIVE );
|
||||
gl_particle_min_size = Cvar_Get( "gl_particle_min_size", "2", CVAR_ARCHIVE );
|
||||
gl_particle_max_size = Cvar_Get( "gl_particle_max_size", "40", CVAR_ARCHIVE );
|
||||
gl_particle_size = Cvar_Get( "gl_particle_size", "40", CVAR_ARCHIVE );
|
||||
gl_particle_att_a = Cvar_Get( "gl_particle_att_a", "0.01", CVAR_ARCHIVE );
|
||||
gl_particle_att_b = Cvar_Get( "gl_particle_att_b", "0.0", CVAR_ARCHIVE );
|
||||
gl_particle_att_c = Cvar_Get( "gl_particle_att_c", "0.01", CVAR_ARCHIVE );
|
||||
|
||||
r_bloom = ri.Cvar_Get( "r_bloom", "0", CVAR_ARCHIVE );
|
||||
r_bloom_alpha = ri.Cvar_Get( "r_bloom_alpha", "0.5", CVAR_ARCHIVE );
|
||||
r_bloom_diamond_size = ri.Cvar_Get( "r_bloom_diamond_size", "8", CVAR_ARCHIVE );
|
||||
r_bloom_intensity = ri.Cvar_Get( "r_bloom_intensity", "0.6", CVAR_ARCHIVE );
|
||||
r_bloom_darken = ri.Cvar_Get( "r_bloom_darken", "4", CVAR_ARCHIVE );
|
||||
r_bloom_sample_size = ri.Cvar_Get( "r_bloom_sample_size", "128", CVAR_ARCHIVE );
|
||||
r_bloom_fast_sample = ri.Cvar_Get( "r_bloom_fast_sample", "0", CVAR_ARCHIVE );
|
||||
r_bloom = Cvar_Get( "r_bloom", "0", CVAR_ARCHIVE );
|
||||
r_bloom_alpha = Cvar_Get( "r_bloom_alpha", "0.5", CVAR_ARCHIVE );
|
||||
r_bloom_diamond_size = Cvar_Get( "r_bloom_diamond_size", "8", CVAR_ARCHIVE );
|
||||
r_bloom_intensity = Cvar_Get( "r_bloom_intensity", "0.6", CVAR_ARCHIVE );
|
||||
r_bloom_darken = Cvar_Get( "r_bloom_darken", "4", CVAR_ARCHIVE );
|
||||
r_bloom_sample_size = Cvar_Get( "r_bloom_sample_size", "128", CVAR_ARCHIVE );
|
||||
r_bloom_fast_sample = Cvar_Get( "r_bloom_fast_sample", "0", CVAR_ARCHIVE );
|
||||
|
||||
r_minimap_size = ri.Cvar_Get ("r_minimap_size", "256", CVAR_ARCHIVE );
|
||||
r_minimap_zoom = ri.Cvar_Get ("r_minimap_zoom", "1", CVAR_ARCHIVE );
|
||||
r_minimap_style = ri.Cvar_Get ("r_minimap_style", "1", CVAR_ARCHIVE );
|
||||
r_minimap = ri.Cvar_Get("r_minimap", "0", CVAR_ARCHIVE );
|
||||
r_minimap_size = Cvar_Get ("r_minimap_size", "256", CVAR_ARCHIVE );
|
||||
r_minimap_zoom = Cvar_Get ("r_minimap_zoom", "1", CVAR_ARCHIVE );
|
||||
r_minimap_style = Cvar_Get ("r_minimap_style", "1", CVAR_ARCHIVE );
|
||||
r_minimap = Cvar_Get("r_minimap", "0", CVAR_ARCHIVE );
|
||||
|
||||
gl_modulate = ri.Cvar_Get ("gl_modulate", "1", CVAR_ARCHIVE );
|
||||
gl_log = ri.Cvar_Get( "gl_log", "0", 0 );
|
||||
gl_bitdepth = ri.Cvar_Get( "gl_bitdepth", "0", 0 );
|
||||
gl_mode = ri.Cvar_Get( "gl_mode", "3", CVAR_ARCHIVE );
|
||||
gl_lightmap = ri.Cvar_Get ("gl_lightmap", "0", 0);
|
||||
gl_shadows = ri.Cvar_Get ("gl_shadows", "0", CVAR_ARCHIVE );
|
||||
gl_dynamic = ri.Cvar_Get ("gl_dynamic", "1", 0);
|
||||
gl_nobind = ri.Cvar_Get ("gl_nobind", "0", 0);
|
||||
gl_round_down = ri.Cvar_Get ("gl_round_down", "1", 0);
|
||||
gl_picmip = ri.Cvar_Get ("gl_picmip", "0", 0);
|
||||
gl_skymip = ri.Cvar_Get ("gl_skymip", "0", 0);
|
||||
gl_showtris = ri.Cvar_Get ("gl_showtris", "0", 0);
|
||||
gl_ztrick = ri.Cvar_Get ("gl_ztrick", "0", 0);
|
||||
gl_finish = ri.Cvar_Get ("gl_finish", "0", CVAR_ARCHIVE);
|
||||
gl_clear = ri.Cvar_Get ("gl_clear", "0", 0);
|
||||
gl_cull = ri.Cvar_Get ("gl_cull", "1", 0);
|
||||
gl_polyblend = ri.Cvar_Get ("gl_polyblend", "1", 0);
|
||||
gl_flashblend = ri.Cvar_Get ("gl_flashblend", "0", 0);
|
||||
gl_playermip = ri.Cvar_Get ("gl_playermip", "0", 0);
|
||||
gl_texturemode = ri.Cvar_Get( "gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE );
|
||||
gl_texturealphamode = ri.Cvar_Get( "gl_texturealphamode", "default", CVAR_ARCHIVE );
|
||||
gl_texturesolidmode = ri.Cvar_Get( "gl_texturesolidmode", "default", CVAR_ARCHIVE );
|
||||
gl_lockpvs = ri.Cvar_Get( "gl_lockpvs", "0", 0 );
|
||||
gl_modulate = Cvar_Get ("gl_modulate", "1", CVAR_ARCHIVE );
|
||||
gl_log = Cvar_Get( "gl_log", "0", 0 );
|
||||
gl_bitdepth = Cvar_Get( "gl_bitdepth", "0", 0 );
|
||||
gl_mode = Cvar_Get( "gl_mode", "3", CVAR_ARCHIVE );
|
||||
gl_lightmap = Cvar_Get ("gl_lightmap", "0", 0);
|
||||
gl_shadows = Cvar_Get ("gl_shadows", "0", CVAR_ARCHIVE );
|
||||
gl_dynamic = Cvar_Get ("gl_dynamic", "1", 0);
|
||||
gl_nobind = Cvar_Get ("gl_nobind", "0", 0);
|
||||
gl_round_down = Cvar_Get ("gl_round_down", "1", 0);
|
||||
gl_picmip = Cvar_Get ("gl_picmip", "0", 0);
|
||||
gl_skymip = Cvar_Get ("gl_skymip", "0", 0);
|
||||
gl_showtris = Cvar_Get ("gl_showtris", "0", 0);
|
||||
gl_ztrick = Cvar_Get ("gl_ztrick", "0", 0);
|
||||
gl_finish = Cvar_Get ("gl_finish", "0", CVAR_ARCHIVE);
|
||||
gl_clear = Cvar_Get ("gl_clear", "0", 0);
|
||||
gl_cull = Cvar_Get ("gl_cull", "1", 0);
|
||||
gl_polyblend = Cvar_Get ("gl_polyblend", "1", 0);
|
||||
gl_flashblend = Cvar_Get ("gl_flashblend", "0", 0);
|
||||
gl_playermip = Cvar_Get ("gl_playermip", "0", 0);
|
||||
gl_texturemode = Cvar_Get( "gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", CVAR_ARCHIVE );
|
||||
gl_texturealphamode = Cvar_Get( "gl_texturealphamode", "default", CVAR_ARCHIVE );
|
||||
gl_texturesolidmode = Cvar_Get( "gl_texturesolidmode", "default", CVAR_ARCHIVE );
|
||||
gl_lockpvs = Cvar_Get( "gl_lockpvs", "0", 0 );
|
||||
|
||||
gl_vertex_arrays = ri.Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
|
||||
gl_vertex_arrays = Cvar_Get( "gl_vertex_arrays", "0", CVAR_ARCHIVE );
|
||||
|
||||
gl_ext_swapinterval = ri.Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
|
||||
gl_ext_palettedtexture = ri.Cvar_Get( "gl_ext_palettedtexture", "0", CVAR_ARCHIVE );
|
||||
gl_ext_multitexture = ri.Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE );
|
||||
gl_ext_pointparameters = ri.Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
|
||||
gl_ext_compiled_vertex_array = ri.Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
|
||||
gl_ext_swapinterval = Cvar_Get( "gl_ext_swapinterval", "1", CVAR_ARCHIVE );
|
||||
gl_ext_palettedtexture = Cvar_Get( "gl_ext_palettedtexture", "0", CVAR_ARCHIVE );
|
||||
gl_ext_multitexture = Cvar_Get( "gl_ext_multitexture", "1", CVAR_ARCHIVE );
|
||||
gl_ext_pointparameters = Cvar_Get( "gl_ext_pointparameters", "1", CVAR_ARCHIVE );
|
||||
gl_ext_compiled_vertex_array = Cvar_Get( "gl_ext_compiled_vertex_array", "1", CVAR_ARCHIVE );
|
||||
|
||||
gl_drawbuffer = ri.Cvar_Get( "gl_drawbuffer", "GL_BACK", 0 );
|
||||
gl_swapinterval = ri.Cvar_Get( "gl_swapinterval", "1", CVAR_ARCHIVE );
|
||||
gl_drawbuffer = Cvar_Get( "gl_drawbuffer", "GL_BACK", 0 );
|
||||
gl_swapinterval = Cvar_Get( "gl_swapinterval", "1", CVAR_ARCHIVE );
|
||||
|
||||
gl_saturatelighting = ri.Cvar_Get( "gl_saturatelighting", "0", 0 );
|
||||
gl_saturatelighting = Cvar_Get( "gl_saturatelighting", "0", 0 );
|
||||
|
||||
gl_3dlabs_broken = ri.Cvar_Get( "gl_3dlabs_broken", "1", CVAR_ARCHIVE );
|
||||
gl_3dlabs_broken = Cvar_Get( "gl_3dlabs_broken", "1", CVAR_ARCHIVE );
|
||||
|
||||
vid_fullscreen = ri.Cvar_Get( "vid_fullscreen", "0", CVAR_ARCHIVE );
|
||||
vid_gamma = ri.Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
|
||||
r_fullscreen = Cvar_Get( "r_fullscreen", "0", CVAR_ARCHIVE );
|
||||
vid_gamma = Cvar_Get( "vid_gamma", "1.0", CVAR_ARCHIVE );
|
||||
|
||||
ri.Cmd_AddCommand( "imagelist", R_ImageList_f );
|
||||
ri.Cmd_AddCommand( "modellist", Mod_Modellist_f );
|
||||
ri.Cmd_AddCommand( "gl_strings", GL_Strings_f );
|
||||
Cmd_AddCommand( "imagelist", R_ImageList_f );
|
||||
Cmd_AddCommand( "modellist", Mod_Modellist_f );
|
||||
Cmd_AddCommand( "gl_strings", GL_Strings_f );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1015,16 +1015,16 @@ bool R_SetMode (void)
|
|||
rserr_t err;
|
||||
bool fullscreen;
|
||||
|
||||
if ( vid_fullscreen->modified && !gl_config.allow_cds )
|
||||
if ( r_fullscreen->modified && !gl_config.allow_cds )
|
||||
{
|
||||
MsgWarn("R_SetMode: CDS not allowed with this driver\n" );
|
||||
ri.Cvar_SetValue( "vid_fullscreen", !vid_fullscreen->value );
|
||||
vid_fullscreen->modified = false;
|
||||
ri.Cvar_SetValue( "r_fullscreen", !r_fullscreen->value );
|
||||
r_fullscreen->modified = false;
|
||||
}
|
||||
|
||||
fullscreen = vid_fullscreen->value;
|
||||
fullscreen = r_fullscreen->value;
|
||||
|
||||
vid_fullscreen->modified = false;
|
||||
r_fullscreen->modified = false;
|
||||
gl_mode->modified = false;
|
||||
|
||||
if ( ( err = GLimp_SetMode( &vid.width, &vid.height, gl_mode->value, fullscreen ) ) == rserr_ok )
|
||||
|
@ -1035,8 +1035,8 @@ bool R_SetMode (void)
|
|||
{
|
||||
if ( err == rserr_invalid_fullscreen )
|
||||
{
|
||||
ri.Cvar_SetValue( "vid_fullscreen", 0);
|
||||
vid_fullscreen->modified = false;
|
||||
ri.Cvar_SetValue( "r_fullscreen", 0);
|
||||
r_fullscreen->modified = false;
|
||||
MsgWarn("R_SetMode: fullscreen unavailable in this mode\n" );
|
||||
if ( ( err = GLimp_SetMode( &vid.width, &vid.height, gl_mode->value, false ) ) == rserr_ok )
|
||||
return true;
|
||||
|
|
|
@ -40,8 +40,6 @@ bool GLimp_InitGL (void);
|
|||
glwstate_t glw_state;
|
||||
static char wndname[128];
|
||||
|
||||
extern cvar_t *vid_fullscreen;
|
||||
|
||||
static bool VerifyDriver( void )
|
||||
{
|
||||
char buffer[1024];
|
||||
|
@ -65,11 +63,11 @@ static bool VerifyDriver( void )
|
|||
bool VID_CreateWindow( int width, int height, bool fullscreen )
|
||||
{
|
||||
WNDCLASS wc;
|
||||
RECT r;
|
||||
cvar_t *vid_xpos, *vid_ypos;
|
||||
int stylebits;
|
||||
int x, y, w, h;
|
||||
int exstyle;
|
||||
RECT r;
|
||||
cvar_t *r_xpos, *r_ypos;
|
||||
int stylebits;
|
||||
int x, y, w, h;
|
||||
int exstyle;
|
||||
|
||||
strcpy(wndname, FS_Title ); //critical stuff.
|
||||
|
||||
|
@ -119,10 +117,10 @@ bool VID_CreateWindow( int width, int height, bool fullscreen )
|
|||
}
|
||||
else
|
||||
{
|
||||
vid_xpos = ri.Cvar_Get ("vid_xpos", "0", 0);
|
||||
vid_ypos = ri.Cvar_Get ("vid_ypos", "0", 0);
|
||||
x = vid_xpos->value;
|
||||
y = vid_ypos->value;
|
||||
r_xpos = Cvar_Get ("r_xpos", "0", 0);
|
||||
r_ypos = Cvar_Get ("r_ypos", "0", 0);
|
||||
x = r_xpos->value;
|
||||
y = r_ypos->value;
|
||||
}
|
||||
|
||||
glw_state.hWnd = CreateWindowEx( exstyle, WINDOW_CLASS_NAME, wndname, stylebits, x, y, w, h, NULL, NULL, glw_state.hInstance, NULL);
|
||||
|
@ -543,7 +541,7 @@ void GLimp_AppActivate( bool active )
|
|||
}
|
||||
else
|
||||
{
|
||||
if ( vid_fullscreen->value )
|
||||
if ( r_fullscreen->value )
|
||||
ShowWindow( glw_state.hWnd, SW_MINIMIZE );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -304,7 +304,7 @@ void R_InitTextures( void )
|
|||
int texsize, i, j;
|
||||
|
||||
r_imagepool = Mem_AllocPool("Texture Pool");
|
||||
gl_maxsize = ri.Cvar_Get ("gl_maxsize", "0", 0);
|
||||
gl_maxsize = Cvar_Get ("gl_maxsize", "0", 0);
|
||||
|
||||
qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &texsize);
|
||||
if (gl_maxsize->value > texsize) ri.Cvar_SetValue ("gl_maxsize", texsize);
|
||||
|
@ -320,7 +320,7 @@ void R_InitTextures( void )
|
|||
registration_sequence = 1;
|
||||
|
||||
// init intensity conversions
|
||||
intensity = ri.Cvar_Get ("intensity", "2", 0);
|
||||
intensity = Cvar_Get ("intensity", "2", 0);
|
||||
if ( intensity->value <= 1 ) ri.Cvar_Set( "intensity", "1" );
|
||||
gl_state.inverse_intensity = 1 / intensity->value;
|
||||
|
||||
|
|
Reference in New Issue