Quake 2 Oop Conversion Project - Source Diff 3.05 vs 3.14 - g_cmds.c
diff -s -r q2_305/g_cmds.c q2_314/g_cmds.c
Left File < - 3.05/g_cmds.c
Right File > - 3.14/g_cmds.c
Back to Index
5c5,47
< void SelectNextItem (edict_t *ent)
---
> char *ClientTeam (edict_t *ent)
> {
> char *p;
> static char value[512];
>
> value[0] = 0;
>
> if (!ent->client)
> return value;
>
> strcpy(value, Info_ValueForKey (ent->client->pers.userinfo, "skin"));
> p = strchr(value, '/');
> if (!p)
> return value;
>
> if ((int)(dmflags->value) & DF_MODELTEAMS)
> {
> *p = 0;
> return value;
> }
>
> // if ((int)(dmflags->value) & DF_SKINTEAMS)
> return ++p;
> }
>
> qboolean OnSameTeam (edict_t *ent1, edict_t *ent2)
> {
> char ent1Team [512];
> char ent2Team [512];
>
> if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
> return false;
>
> strcpy (ent1Team, ClientTeam (ent1));
> strcpy (ent2Team, ClientTeam (ent2));
>
> if (strcmp(ent1Team, ent2Team) == 0)
> return true;
> return false;
> }
>
>
> void SelectNextItem (edict_t *ent, int itflags)
21a64,65
> if (!(it->flags & itflags))
> continue;
30c74
< void SelectPrevItem (edict_t *ent)
---
> void SelectPrevItem (edict_t *ent, int itflags)
46a91,92
> if (!(it->flags & itflags))
> continue;
55,56d100
<
<
66c110
< SelectNextItem (ent);
---
> SelectNextItem (ent, -1);
85a130
> edict_t *it_ent;
100c145
< if (give_all || Q_stricmp(name, "health") == 0)
---
> if (give_all || Q_stricmp(gi.argv(1), "health") == 0)
103c148
< ent->health += atoi(gi.argv(2));
---
> ent->health = atoi(gi.argv(2));
143a189,194
> it = FindItem("Jacket Armor");
> ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
>
> it = FindItem("Combat Armor");
> ent->client->pers.inventory[ITEM_INDEX(it)] = 0;
>
151a203,216
> if (give_all || Q_stricmp(name, "Power Shield") == 0)
> {
> it = FindItem("Power Shield");
> it_ent = G_Spawn();
> it_ent->classname = it->classname;
> SpawnItem (it_ent, it);
> Touch_Item (it_ent, ent, NULL, NULL);
> if (it_ent->inuse)
> G_FreeEdict(it_ent);
>
> if (!give_all)
> return;
> }
>
186,190c251
< if (it->flags & IT_WEAPON)
< {
< ent->client->pers.inventory[index] += 1;
< }
< else if (it->flags & IT_AMMO)
---
> if (it->flags & IT_AMMO)
193c254
< ent->client->pers.inventory[index] += atoi(gi.argv(2));
---
> ent->client->pers.inventory[index] = atoi(gi.argv(2));
199c260,265
< ent->client->pers.inventory[index] += 1;
---
> it_ent = G_Spawn();
> it_ent->classname = it->classname;
> SpawnItem (it_ent, it);
> Touch_Item (it_ent, ent, NULL, NULL);
> if (it_ent->inuse)
> G_FreeEdict(it_ent);
313a380,384
> if (!it->use)
> {
> gi.cprintf (ent, PRINT_HIGH, "Item is not usable.\n");
> return;
> }
338,340d408
< if (!(deathmatch->value)) // no dropping in single player
< return;
<
347a416,420
> if (!it->drop)
> {
> gi.cprintf (ent, PRINT_HIGH, "Item is not dropable.\n");
> return;
> }
370a444,446
> cl->showscores = false;
> cl->showhelp = false;
>
378d453
< cl->showscores = false;
487a563,589
> Cmd_WeapLast_f
> =================
> */
> void Cmd_WeapLast_f (edict_t *ent)
> {
> gclient_t *cl;
> int index;
> gitem_t *it;
>
> cl = ent->client;
>
> if (!cl->pers.weapon || !cl->pers.lastweapon)
> return;
>
> index = ITEM_INDEX(cl->pers.lastweapon);
> if (!cl->pers.inventory[index])
> return;
> it = &itemlist[index];
> if (!it->use)
> return;
> if (! (it->flags & IT_WEAPON) )
> return;
> it->use (ent, it);
> }
>
> /*
> =================
518a621,622
> if((level.time - ent->client->respawn_time) < 5)
> return;
520a625
> meansOfDeath = MOD_SUICIDE;
534a640
> ent->client->showhelp = false;
537a644,704
>
> int PlayerSort (void const *a, void const *b)
> {
> int anum, bnum;
>
> anum = *(int *)a;
> bnum = *(int *)b;
>
> anum = game.clients[anum].ps.stats[STAT_FRAGS];
> bnum = game.clients[bnum].ps.stats[STAT_FRAGS];
>
> if (anum < bnum)
> return -1;
> if (anum > bnum)
> return 1;
> return 0;
> }
>
> /*
> =================
> Cmd_Players_f
> =================
> */
> void Cmd_Players_f (edict_t *ent)
> {
> int i;
> int count;
> char small[64];
> char large[1280];
> int index[256];
>
> count = 0;
> for (i = 0 ; i < maxclients->value ; i++)
> if (game.clients[i].pers.connected)
> {
> index[count] = i;
> count++;
> }
>
> // sort by frags
> qsort (index, count, sizeof(index[0]), PlayerSort);
>
> // print information
> large[0] = 0;
>
> for (i = 0 ; i < count ; i++)
> {
> Com_sprintf (small, sizeof(small), "%3i %s\n",
> game.clients[index[i]].ps.stats[STAT_FRAGS],
> game.clients[index[i]].pers.netname);
> if (strlen (small) + strlen(large) > sizeof(large) - 100 )
> { // can't print all of them in one packet
> strcat (large, "...\n");
> break;
> }
> strcat (large, small);
> }
>
> gi.cprintf (ent, PRINT_HIGH, "%s\n%i players\n", large, count);
> }
>
589a757,822
> ==================
> Cmd_Say_f
> ==================
> */
> void Cmd_Say_f (edict_t *ent, qboolean team, qboolean arg0)
> {
> int j;
> edict_t *other;
> char *p;
> char text[2048];
>
> if (gi.argc () < 2 && !arg0)
> return;
>
> if (!((int)(dmflags->value) & (DF_MODELTEAMS | DF_SKINTEAMS)))
> team = false;
>
> if (team)
> Com_sprintf (text, sizeof(text), "(%s): ", ent->client->pers.netname);
> else
> Com_sprintf (text, sizeof(text), "%s: ", ent->client->pers.netname);
>
> if (arg0)
> {
> strcat (text, gi.argv(0));
> strcat (text, " ");
> strcat (text, gi.args());
> }
> else
> {
> p = gi.args();
>
> if (*p == '"')
> {
> p++;
> p[strlen(p)-1] = 0;
> }
> strcat(text, p);
> }
>
> // don't let text be too long for malicious reasons
> if (strlen(text) > 150)
> text[150] = 0;
>
> strcat(text, "\n");
>
> if (dedicated->value)
> gi.cprintf(NULL, PRINT_CHAT, "%s", text);
>
> for (j = 1; j <= game.maxclients; j++)
> {
> other = &g_edicts[j];
> if (!other->inuse)
> continue;
> if (!other->client)
> continue;
> if (team)
> {
> if (!OnSameTeam(ent, other))
> continue;
> }
> gi.cprintf(other, PRINT_CHAT, "%s", text);
> }
> }
>
> /*
601a835,864
>
> if (Q_stricmp (cmd, "players") == 0)
> {
> Cmd_Players_f (ent);
> return;
> }
> if (Q_stricmp (cmd, "say") == 0)
> {
> Cmd_Say_f (ent, false, false);
> return;
> }
> if (Q_stricmp (cmd, "say_team") == 0)
> {
> Cmd_Say_f (ent, true, false);
> return;
> }
> if (Q_stricmp (cmd, "score") == 0)
> {
> Cmd_Score_f (ent);
> return;
> }
> if (Q_stricmp (cmd, "help") == 0)
> {
> Cmd_Help_f (ent);
> return;
> }
>
> if (level.intermissiontime)
> return;
>
614,615d876
< else if (Q_stricmp (cmd, "help") == 0)
< Cmd_Help_f (ent);
619c880
< SelectNextItem (ent);
---
> SelectNextItem (ent, -1);
621c882,890
< SelectPrevItem (ent);
---
> SelectPrevItem (ent, -1);
> else if (Q_stricmp (cmd, "invnextw") == 0)
> SelectNextItem (ent, IT_WEAPON);
> else if (Q_stricmp (cmd, "invprevw") == 0)
> SelectPrevItem (ent, IT_WEAPON);
> else if (Q_stricmp (cmd, "invnextp") == 0)
> SelectNextItem (ent, IT_POWERUP);
> else if (Q_stricmp (cmd, "invprevp") == 0)
> SelectPrevItem (ent, IT_POWERUP);
629a899,900
> else if (Q_stricmp (cmd, "weaplast") == 0)
> Cmd_WeapLast_f (ent);
636,649c907,908
< else if (Q_stricmp (cmd, "gameversion") == 0)
< {
< gi.cprintf (ent, PRINT_HIGH, "%s : %s\n", GAMEVERSION, __DATE__);
< }
< else if (Q_stricmp (cmd, "fov") == 0)
< {
< ent->client->ps.fov = atoi(gi.argv(1));
< if (ent->client->ps.fov < 1)
< ent->client->ps.fov = 90;
< else if (ent->client->ps.fov > 160)
< ent->client->ps.fov = 160;
< }
< else
< gi.cprintf (ent, PRINT_HIGH, "Bad command: %s\n", cmd);
---
> else // anything that doesn't match a command will be a chat
> Cmd_Say_f (ent, false, true);
651d909
<