Skip to content

Commit 92f38d9

Browse files
committed
Server: Proper handling of SV_ParseClientCommand
1 parent 1ed974f commit 92f38d9

1 file changed

Lines changed: 15 additions & 137 deletions

File tree

source/server/player.qc

Lines changed: 15 additions & 137 deletions
Original file line numberDiff line numberDiff line change
@@ -678,146 +678,24 @@ void() SetChangeParms =
678678
{
679679
};
680680

681-
void(string com) SV_ParseClientCommand =
682-
{
683-
684-
if(com == "joingame")
685-
{
686-
if(self.isspec)
687-
{
688-
bprint(PRINT_HIGH, self.netname);
689-
bprint(PRINT_HIGH, " has joined the game.\n");
690-
PlayerSpawn();
691-
}
692-
else
693-
sprint(self, PRINT_HIGH, "You're already in game!\n");
694-
}
695-
else if(com == "specgame")
696-
{
697-
if(self.isspec)
698-
return;
699-
else
700-
{
701-
coop = 1;
681+
void(string command_string) SV_ParseClientCommand =
682+
{
683+
float skip = true;
684+
float fvalue;
685+
tokenize(command_string);
686+
string cmd = argv(0);
702687

703-
/*SpectatorSpawn();
704-
bprint(PRINT_HIGH, self.netname); //print player name
705-
bprint(PRINT_HIGH, " has joined the spectators.\n");*/
706-
707-
PlayerSpawn();
708-
}
709-
}
710-
else if(com == "pause")
711-
{
712-
static float paused;
713-
paused = !paused;
714-
#ifdef PC
715-
setpause(paused);
716-
#endif
717-
}
718-
else if (com == "noclip")
719-
{
720-
#ifndef PC
721-
entity benis = self;
722-
other = find(world, classname, "player");
723-
self = other;
724-
#endif
725-
726-
if (self.movetype == MOVETYPE_WALK)
727-
self.movetype = MOVETYPE_NOCLIP;
728-
else
729-
self.movetype = MOVETYPE_WALK;
730-
731-
#ifndef PC
732-
localcmd(com);
733-
self = benis;
734-
#endif
735-
}
736-
else if (com == "god")
688+
switch (cmd)
737689
{
738-
#ifndef PC
739-
entity benis2 = self;
740-
other = find(world, classname, "player");
741-
self = other;
742-
#endif
743-
744-
if (!(self.flags & FL_GODMODE))
745-
self.flags = self.flags | FL_GODMODE;
746-
else
747-
self.flags = self.flags & (~FL_GODMODE);
748-
749-
#ifndef PC
750-
localcmd(com);
751-
self = benis2;
752-
#endif
753-
}
754-
else
755-
{
756-
tokenize(com);
757-
758-
switch(argv(0))
759-
{
760-
case "give":
761-
entity tempe = self;
762-
other = find(world, classname, "player");
763-
self = other;
764-
765-
float wep = stof(argv(1));
766-
767-
if (wep) {
768-
if (!self.secondaryweapon) {
769-
WeaponSwitch(self);
770-
}
771-
772-
float startframe, endframe;
773-
string modelname;
774-
775-
self.weapon = wep;
776-
self.currentammo = getWeaponAmmo(wep);
777-
self.currentmag = getWeaponMag(wep);
778-
if (IsDualWeapon(wep)) {
779-
self.currentmag2 = self.currentmag;
780-
}
781-
782-
self.weaponskin = GetWepSkin(self.weapon);
783-
784-
startframe = GetFrame(self.weapon,TAKE_OUT_START);
785-
endframe = GetFrame(self.weapon,TAKE_OUT_END);
786-
modelname = GetWeaponModel(wep, 0);
787-
788-
SwitchWeapon(wep);
789-
790-
Set_W_Frame (startframe, endframe, 0, 0, 0, SUB_Null, modelname, false, S_BOTH);
791-
792-
self.reload_delay2 = self.fire_delay2 = self.reload_delay = self.fire_delay = 0;
793-
794-
#ifndef PC
795-
self.Weapon_Name = GetWeaponName(self.weapon);
796-
#endif
797-
}
798-
break;
799-
case "nextround":
800-
rounds++;
801-
break;
802-
case "prevround":
803-
rounds--;
804-
break;
805-
case "addmoney":
806-
entity tempe1 = self;
807-
other = find(world, classname, "player");
808-
self = other;
809-
810-
addmoney(self, stof(argv(1)), 1);
811-
812-
self = tempe1;
813-
break;
814-
default:
815-
#ifndef PC
816-
bprint(PRINT_HIGH, "Command not found in QC\n");
817-
#endif
818-
break;
819-
}
690+
case "addmoney":
691+
fvalue = stof(argv(1));
692+
addmoney(self, fvalue, 0);
693+
default: skip = false; break;
820694
}
695+
#ifdef PC
696+
if (skip == false)
697+
clientcommand(self, command_string);
698+
#endif // PC
821699
};
822700

823701
#ifdef PC

0 commit comments

Comments
 (0)