cl_inv.c reformat und in Sachen Kommentaren aufgeräumt

This commit is contained in:
Yamagi Burmeister 2010-06-18 07:48:31 +00:00
parent 9aeacdc2be
commit a463c1e44b
2 changed files with 41 additions and 45 deletions

View file

@ -22,8 +22,8 @@
extern struct model_s *cl_mod_powerscreen; extern struct model_s *cl_mod_powerscreen;
int vidref_val; int vidref_val;
int bitcounts[32]; /* just for protocol profiling */ int bitcounts[32]; /* just for protocol profiling */
int CL_ParseEntityBits (unsigned *bits) { int CL_ParseEntityBits (unsigned *bits) {
unsigned b, total; unsigned b, total;
int i; int i;

View file

@ -1,31 +1,25 @@
/* /*
Copyright (C) 1997-2001 Id Software, Inc. * Copyright (C) 1997-2001 Id Software, Inc.
*
This program is free software; you can redistribute it and/or * This program is free software; you can redistribute it and/or modify it under
modify it under the terms of the GNU General Public License * the terms of the GNU General Public License as published by the Free
as published by the Free Software Foundation; either version 2 * Software Foundation; either version 2 of the License, or (at your option)
of the License, or (at your option) any later version. * any later version.
*
This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful, but WITHOUT
but WITHOUT ANY WARRANTY; without even the implied warranty of * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * FITNESS FOR A PARTICULAR PURPOSE.
*
See the GNU General Public License for more details. * See the GNU General Public License for more details.
*
You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License along with
along with this program; if not, write to the Free Software * this program; if not, write to the Free Software Foundation, Inc., 59
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/ */
// cl_inv.c -- client inventory screen
#include "header/client.h" #include "header/client.h"
/*
================
CL_ParseInventory
================
*/
void CL_ParseInventory (void) void CL_ParseInventory (void)
{ {
int i; int i;
@ -34,17 +28,11 @@ void CL_ParseInventory (void)
cl.inventory[i] = MSG_ReadShort (&net_message); cl.inventory[i] = MSG_ReadShort (&net_message);
} }
/*
================
Inv_DrawString
================
*/
static void Inv_DrawString (int x, int y, char *string) static void Inv_DrawString (int x, int y, char *string)
{ {
while (*string) while (*string)
{ {
re.DrawChar (x, y, *string); re.DrawChar (x, y, *string);
x+=8; x+=8;
string++; string++;
} }
@ -56,11 +44,6 @@ static void SetStringHighBit (char *s)
*s++ |= 128; *s++ |= 128;
} }
/*
================
CL_DrawInventory
================
*/
#define DISPLAY_ITEMS 17 #define DISPLAY_ITEMS 17
void CL_DrawInventory (void) void CL_DrawInventory (void)
@ -79,10 +62,12 @@ void CL_DrawInventory (void)
num = 0; num = 0;
selected_num = 0; selected_num = 0;
for (i=0 ; i<MAX_ITEMS ; i++) for (i=0 ; i<MAX_ITEMS ; i++)
{ {
if (i==selected) if (i==selected)
selected_num = num; selected_num = num;
if (cl.inventory[i]) if (cl.inventory[i])
{ {
index[num] = i; index[num] = i;
@ -90,32 +75,41 @@ void CL_DrawInventory (void)
} }
} }
// determine scroll point /* determine scroll point */
top = selected_num - DISPLAY_ITEMS/2; top = selected_num - DISPLAY_ITEMS/2;
if (num - top < DISPLAY_ITEMS) if (num - top < DISPLAY_ITEMS)
top = num - DISPLAY_ITEMS; top = num - DISPLAY_ITEMS;
if (top < 0) if (top < 0)
top = 0; top = 0;
x = (viddef.width-256)/2; x = (viddef.width-256)/2;
y = (viddef.height-240)/2; y = (viddef.height-240)/2;
// repaint everything next frame /* repaint everything next frame */
SCR_DirtyScreen (); SCR_DirtyScreen ();
re.DrawPic (x, y+8, "inventory"); re.DrawPic (x, y+8, "inventory");
y += 24; y += 24;
x += 24; x += 24;
Inv_DrawString (x, y, "hotkey ### item"); Inv_DrawString (x, y, "hotkey ### item");
Inv_DrawString (x, y+8, "------ --- ----"); Inv_DrawString (x, y+8, "------ --- ----");
y += 16; y += 16;
for (i=top ; i<num && i < top+DISPLAY_ITEMS ; i++) for (i=top ; i<num && i < top+DISPLAY_ITEMS ; i++)
{ {
item = index[i]; item = index[i];
// search for a binding /* search for a binding */
Com_sprintf (binding, sizeof(binding), "use %s", cl.configstrings[CS_ITEMS+item]); Com_sprintf (binding, sizeof(binding), "use %s", cl.configstrings[CS_ITEMS+item]);
bind = ""; bind = "";
for (j=0 ; j<256 ; j++) for (j=0 ; j<256 ; j++)
if (keybindings[j] && !Q_stricmp (keybindings[j], binding)) if (keybindings[j] && !Q_stricmp (keybindings[j], binding))
{ {
@ -124,18 +118,20 @@ void CL_DrawInventory (void)
} }
Com_sprintf (string, sizeof(string), "%6s %3i %s", bind, cl.inventory[item], Com_sprintf (string, sizeof(string), "%6s %3i %s", bind, cl.inventory[item],
cl.configstrings[CS_ITEMS+item] );
cl.configstrings[CS_ITEMS+item] );
if (item != selected) if (item != selected)
SetStringHighBit (string); SetStringHighBit (string);
else // draw a blinky cursor by the selected item else
{ {
/* draw a blinky cursor by the selected item */
if ( (int)(cls.realtime*10) & 1) if ( (int)(cls.realtime*10) & 1)
re.DrawChar (x-8, y, 15); re.DrawChar (x-8, y, 15);
} }
Inv_DrawString (x, y, string); Inv_DrawString (x, y, string);
y += 8; y += 8;
} }
} }