All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Namespaces | Functions | Variables
client.cpp File Reference
#include <boost/algorithm/clamp.hpp>
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <memory>
#include <string>
#include "SDL_opengl.h"
#include <enet/enet.h>
#include "inexor/client/gamemode/bomb_client.hpp"
#include "inexor/client/gamemode/capture_client.hpp"
#include "inexor/client/gamemode/collect_client.hpp"
#include "inexor/client/gamemode/ctf_client.hpp"
#include "inexor/client/gamemode/gamemode_client.hpp"
#include "inexor/client/gamemode/hideandseek_client.hpp"
#include "inexor/client/network.hpp"
#include "inexor/engine/glemu.hpp"
#include "inexor/engine/material.hpp"
#include "inexor/engine/octa.hpp"
#include "inexor/engine/octaedit.hpp"
#include "inexor/engine/octree.hpp"
#include "inexor/engine/particles.hpp"
#include "inexor/engine/rendergl.hpp"
#include "inexor/engine/renderparticles.hpp"
#include "inexor/engine/world.hpp"
#include "inexor/engine/worldio.hpp"
#include "inexor/fpsgame/ai.hpp"
#include "inexor/fpsgame/client.hpp"
#include "inexor/fpsgame/entities.hpp"
#include "inexor/fpsgame/fps.hpp"
#include "inexor/fpsgame/fpsent.hpp"
#include "inexor/fpsgame/fpsstate.hpp"
#include "inexor/fpsgame/guns.hpp"
#include "inexor/fpsgame/render.hpp"
#include "inexor/fpsgame/scoreboard.hpp"
#include "inexor/fpsgame/teaminfo.hpp"
#include "inexor/fpsgame/weapon.hpp"
#include "inexor/gamemode/gamemode.hpp"
#include "inexor/io/Error.hpp"
#include "inexor/io/Logging.hpp"
#include "inexor/io/filesystem/mediadirs.hpp"
#include "inexor/io/filesystem/path.hpp"
#include "inexor/io/legacy/stream.hpp"
#include "inexor/model/ragdoll.hpp"
#include "inexor/network/SharedVar.hpp"
#include "inexor/network/legacy/administration.hpp"
#include "inexor/network/legacy/buffer_types.hpp"
#include "inexor/network/legacy/crypto.hpp"
#include "inexor/network/legacy/cube_network.hpp"
#include "inexor/network/legacy/game_types.hpp"
#include "inexor/physics/physics.hpp"
#include "inexor/shared/command.hpp"
#include "inexor/shared/cube_endian.hpp"
#include "inexor/shared/cube_formatting.hpp"
#include "inexor/shared/cube_loops.hpp"
#include "inexor/shared/cube_tools.hpp"
#include "inexor/shared/cube_types.hpp"
#include "inexor/shared/cube_vector.hpp"
#include "inexor/shared/ents.hpp"
#include "inexor/shared/geom.hpp"
#include "inexor/shared/tools.hpp"
#include "inexor/sound/sound.hpp"
#include "inexor/texture/settexture.hpp"
#include "inexor/texture/slot.hpp"
#include "inexor/ui/legacy/3dgui.hpp"
#include "inexor/util/legacy_time.hpp"


 implementation of basic game functionsand cubescript bindings


 game::VARP (minradarscale, 0, 384, 10000)
 minimap and radar More...
 game::VARP (maxradarscale, 1, 1024, 10000)
 game::VARP (radarteammates, 0, 1, 1)
 game::FVARP (minimapalpha, 0, 1, 1)
float game::calcradarscale ()
 calculate required radar scale More...
void game::drawminimap (fpsent *d, float x, float y, float s)
 draw rotated minimap More...
void game::setradartex ()
 bind the minimap frame's texture More...
void game::drawradar (float x, float y, float s)
 draw radar (a trangle square with matching texture coordinates to be precise) to target coordinates More...
void game::drawteammate (fpsent *d, float x, float y, float s, fpsent *o, float scale)
 draw a specific teamate's icon arrow in minimap More...
void game::setbliptex (int team, const char *type)
 set specific textures for teammates, skulls... on the minimap More...
void game::drawteammates (fpsent *d, float x, float y, float s)
 draw all teamate arrow icons in minimap More...
void game::setclientmode ()
 set game mode pointer More...
 game::VARP (deadpush, 1, 2, 20)
 push dead bodies (?) More...
void game::switchname (const char *name, const char *tag)

team, name and playermodel settings More...

void game::printname ()
 print my own nick name to the game console More...
 game::ICOMMAND (name,"sN",(char *s, int *numargs),{if(*numargs > 0) switchname(s, nullptr);else if(!*numargs) printname();else result(colorname(player1));})
 game::ICOMMAND (getname,"",(), result(player1->name))
 game::ICOMMAND (tag,"sN",(char *s, int *numargs),{if(*numargs > 0) switchname("", s);else if(!*numargs) Log.std->info("your tag is: {0}", player1->tag);else result(player1->tag);})
 game::ICOMMAND (gettag,"",(), result(player1->tag))
void game::switchteam (const char *team)
 switch own team More...
void game::printteam ()
 print own team name to the game console More...
 game::ICOMMAND (team,"sN",(char *s, int *numargs),{if(*numargs > 0) switchteam(s);else if(!*numargs) printteam();else result(player1->team);})
 switch team or print team name More...
 game::ICOMMAND (getteam,"",(), result(player1->team))
 cubescript implementation of getteam More...
void game::switchplayermodel (int playermodel)
 switch my player model (inky, ogro..) More...
void game::sendmapinfo ()
 set booleans sendcrc and senditemstoserver if connected. More...
void game::writeclientinfo (stream *f)
 write my player name to a stream More...
bool game::allowedittoggle ()
 check if editing is available More...
void game::edittoggled (bool on)
 send edit toggle to server More...
const char * game::getclientname (int cn)
 get nick name from cn More...
 game::ICOMMAND (getclientname,"i",(int *cn), result(getclientname(*cn)))
const char * game::getclientteam (int cn)
 get team name from cn More...
 game::ICOMMAND (getclientteam,"i",(int *cn), result(getclientteam(*cn)))
int game::getclientmodel (int cn)
 get client player model ID from cn More...
 game::ICOMMAND (getclientmodel,"i",(int *cn), intret(getclientmodel(*cn)))
const char * game::getclienticon (int cn)
 get client icon from cn depends on player model and spectator mode More...
 game::ICOMMAND (getclienticon,"i",(int *cn), result(getclienticon(*cn)))
bool game::ismaster (int cn)
 check if this client is a game master or administrator More...
 game::ICOMMAND (ismaster,"i",(int *cn), intret(ismaster(*cn)?1:0))
bool game::isadmin (int cn)
 check if this client is an administrator More...
 game::ICOMMAND (isadmin,"i",(int *cn), intret(isadmin(*cn)?1:0))
 game::ICOMMAND (getmastermode,"",(), intret(mastermode))
 game::ICOMMAND (mastermodename,"i",(int *mm), result(mastermodename(*mm,"")))
bool game::isspectator (int cn)
 game::ICOMMAND (isspectator,"i",(int *cn), intret(isspectator(*cn)?1:0))
bool game::isai (int cn, int type)
 check if this cn is a bot (computer controlled player) More...
 game::ICOMMAND (isai,"ii",(int *cn, int *type), intret(isai(*cn,*type)?1:0))
int game::parseplayer (const char *arg)
 all functions can be called using client number or full name name should be case sensitive but the engine checks is both ways More...
 game::ICOMMAND (getclientnum,"s",(char *name), intret(name[0]?parseplayer(name):player1->clientnum))
void game::listclients (bool local, bool bots)
 return a list of players More...
 game::ICOMMAND (listclients,"bb",(int *local, int *bots), listclients(*local >0,*bots!=0))
void game::clearbans ()
 server administration More...
 game::COMMAND (clearbans,"")
void game::setteam (const char *arg1, const char *arg2)
 change a players team More...
 game::COMMAND (setteam,"ss")
void game::kick (const char *victim, const char *reason)
 request to kickban a player More...
 game::COMMAND (kick,"ss")
void game::ignore (int cn)
 ignore all chat messags from a certain client number More...
void game::unignore (int cn)
 stop ignoring all chat messages from a certain client number More...
bool game::isignored (int cn)
 cubescript: check if this person is ignored by you More...
 game::ICOMMAND (ignore,"s",(char *arg), ignore(parseplayer(arg)))
 game::ICOMMAND (unignore,"s",(char *arg), unignore(parseplayer(arg)))
 game::ICOMMAND (isignored,"s",(char *arg), intret(isignored(parseplayer(arg))?1:0))
void game::hashpwd (const char *pwd)
 hash setmaster password cn and sessionid are used to hash: servers do to store the hash value. More...
 game::COMMAND (hashpwd,"s")
void game::setmaster (const char *arg, const char *who)
 acquire game master or give game master to players More...
 game::COMMAND (setmaster,"ss")
 game::ICOMMAND (mastermode,"i",(int *val), addmsg(N_MASTERMODE,"ri",*val))
 request to change server master mode (permissions requires) More...
void game::togglespectator (int val, const char *who)
 toggle own spectator or put player into spectator (permissions requred) More...
 game::ICOMMAND (spectator,"is",(int *val, char *who), togglespectator(*val, who))
 game::ICOMMAND (checkmaps,"",(), addmsg(N_CHECKMAPS,"r"))
 ask the server to acquire CRC32 checksum of all player's maps (permissions requred) More...
void game::changemapserv (const char *name, int mode)
 force server to change map (permissions required) More...
void game::setmode (int mode)
 force server to change game mode (permissions required) More...
 game::ICOMMAND (mode,"i",(int *val), setmode(*val))
 set game mode More...
 game::ICOMMAND (getmode,"",(), intret(gamemode))
 get game mode in cubescript More...
 game::ICOMMAND (timeremaining,"i",(int *formatted),{int val=max(maplimit-lastmillis, 0)/1000;if(*formatted){defformatstring(str,"%d:%02d", val/60, val%60);result(str);}else intret(val);})
 return remaining time More...
 game::ICOMMANDS ("m_noitems","i",(int *mode),{int gamemode=*mode;intret(m_noitems);})
 game::ICOMMANDS ("m_noammo","i",(int *mode),{int gamemode=*mode;intret(m_noammo);})
 game::ICOMMANDS ("m_insta","i",(int *mode),{int gamemode=*mode;intret(m_insta);})
 game::ICOMMANDS ("m_tactics","i",(int *mode),{int gamemode=*mode;intret(m_tactics);})
 game::ICOMMANDS ("m_efficiency","i",(int *mode),{int gamemode=*mode;intret(m_efficiency);})
 game::ICOMMANDS ("m_capture","i",(int *mode),{int gamemode=*mode;intret(m_capture);})
 game::ICOMMANDS ("m_regencapture","i",(int *mode),{int gamemode=*mode;intret(m_regencapture);})
 game::ICOMMANDS ("m_ctf","i",(int *mode),{int gamemode=*mode;intret(m_ctf);})
 game::ICOMMANDS ("m_protect","i",(int *mode),{int gamemode=*mode;intret(m_protect);})
 game::ICOMMANDS ("m_hold","i",(int *mode),{int gamemode=*mode;intret(m_hold);})
 game::ICOMMANDS ("m_collect","i",(int *mode),{int gamemode=*mode;intret(m_collect);})
 game::ICOMMANDS ("m_teammode","i",(int *mode),{int gamemode=*mode;intret(m_teammode);})
 game::ICOMMANDS ("m_demo","i",(int *mode),{int gamemode=*mode;intret(m_demo);})
 game::ICOMMANDS ("m_edit","i",(int *mode),{int gamemode=*mode;intret(m_edit);})
 game::ICOMMANDS ("m_lobby","i",(int *mode),{int gamemode=*mode;intret(m_lobby);})
 game::ICOMMANDS ("m_lms","i",(int *mode),{int gamemode=*mode;intret(m_lms);})
 game::ICOMMANDS ("m_bomb","i",(int *mode),{int gamemode=*mode;intret(m_bomb);})
 game::ICOMMANDS ("m_timeforward","i",(int *mode),{int gamemode=*mode;intret(m_timeforward);})
 game::ICOMMANDS ("m_obstacles","i",(int *mode),{int gamemode=*mode;intret(m_obstacles);})
void game::changemap (const char *name, int mode)
 request map change, server may ignore More...
void game::changemap (const char *name)
 validates game mode name and calls changemap above More...
 game::ICOMMAND (map,"s",(char *name), changemap(name))
void game::forceintermission ()
void game::forceedit (const char *name)
 force edit mode More...
void game::newmap (int size)
 request server to start new map (requires editmode) More...
void game::sendclipboard ()
 send copied data from your clipboard to server More...
void game::edittrigger (const selinfo &sel, int op, int arg1, int arg2, int arg3, const VSlot *vs)
 send edit messages to servers More...
void game::printvar (fpsent *d, ident *id)
 print map var change commited by other players in edit mode More...
void game::vartrigger (ident *id)
 change map vars in edit mode in multiplayer More...
void game::broadcastfov (int fov)
void game::pausegame (bool val)
 pause game More...
 game::ICOMMAND (pausegame,"i",(int *val), pausegame(*val > 0))
 game::ICOMMAND (paused,"iN$",(int *val, int *numargs, ident *id),{if(*numargs > 0) pausegame(clampvar(id,*val, 0, 1) > 0);else if(*numargs< 0) intret(gamepaused?1:0);else printvar(id, gamepaused?1:0);})
 cubescript: check if game is paused More...
bool game::ispaused ()
 check if game is paused More...
void game::persistteams (bool val)
 Set reshuffeling behaviour on mapchange according to bool val (true activates persistent teams) More...
 game::ICOMMAND (persistteams,"i",(int *val), persistteams(*val > 0))
bool game::ispersisted ()
bool game::allowmouselook ()
 check if looking around with the mouse is allowed. More...
void game::changegamespeed (int val)
 change game speed (requires permissions) More...
 game::ICOMMAND (gamespeed,"iN$",(int *val, int *numargs, ident *id),{if(*numargs > 0) changegamespeed(clampvar(id,*val, 10, 1000));else if(*numargs< 0) intret(gamespeed);else printvar(id, gamespeed);})
bool game::addmsg (int type, const char *fmt,...)
 add network message More...
void game::connectattempt (const char *mapwish, int modewish, const char *password)
 copy connection password (?) More...
void game::connectfail ()
 reset connection password after connection failed More...
void game::gameconnect ()
 ? More...
void game::gamedisconnect (bool cleanup)
 clean up local storage/vars after disconnect from server More...
void game::toserver (char *text)
 send chat messages to server More...
 game::COMMANDN (say, toserver,"C")
void game::sayteam (char *text)
 send team messages to server More...
 game::COMMAND (sayteam,"C")
void game::sayprivate (int i, char *text)
 game::ICOMMAND (pm,"is",(int *i, char *text), sayprivate(*i, text))
 game::ICOMMAND (servcmd,"C",(char *cmd), addmsg(N_SERVCMD,"rs", cmd))
 send custom server messages to servers this feature is not used on most servers (?) More...
static void game::sendposition (fpsent *d, packetbuf &q)
 network message parser More...
void game::sendposition (fpsent *d, bool reliable)
 send my own player position to server (call function above) More...
void game::sendpositions ()
 ? More...
void game::sendmessages ()
 ? More...
void game::c2sinfo (bool force)
 send update to the server More...
void game::sendintro ()
 send N_CONNECT (with own name, serverpassword, playermodel and fov) More...
void game::updatepos (fpsent *d)
void game::parsepositions (ucharbuf &p)
void game::parsestate (fpsent *d, ucharbuf &p, bool resume=false)
void game::parsemessages (int cn, fpsent *d, ucharbuf &p)
void game::receivefile (packetbuf &p)
void game::parsepacketclient (int chan, packetbuf &p)
void game::getmap ()
 game::COMMAND (getmap,"")
void game::stopdemo ()
 game::COMMAND (stopdemo,"")
void game::recorddemo (int val)
 game::ICOMMAND (recorddemo,"i",(int *val), recorddemo(*val))
void game::cleardemos (int val)
 game::ICOMMAND (cleardemos,"i",(int *val), cleardemos(*val))
void game::getdemo (int i)
 game::ICOMMAND (getdemo,"i",(int *val), getdemo(*val))
void game::listdemos ()
 game::COMMAND (listdemos,"")
void game::sendmap ()
 game::COMMAND (sendmap,"")
void game::gotoplayer (const char *arg)
 game::COMMANDN (goto, gotoplayer,"s")
void game::gotosel ()
 game::COMMAND (gotosel,"")


collectclientmode game::collectmode
bool game::senditemstoserver = false
 after a map change, since server doesn't have map data More...
bool game::sendcrc = false
int game::lastping = 0
bool game::connected = false
bool game::demoplayback = false
bool game::gamepaused = false
bool game::teamspersisted = false
int game::sessionid = 0
int game::mastermode = MM_OPEN
int game::gamespeed = 100
string game::servinfo = ""
string game::connectpass = ""
string game::connectmapwish = ""
int game::connectmodewish = -1
vector< int > game::ignores
 a vector of ignored client numbers (cns) More...
int game::nextmode = INT_MAX
string game::clientmap = ""
int game::needclipboard = -1
 ? More...
vector< uchargame::messages
 collect client to server messages conveniently More...
int game::messagecn = -1
int game::messagereliable = false
SharedVar< int > game::deathscore