From 7ab718f74ecb3fbe1d7d671e1198fa689819ab7f Mon Sep 17 00:00:00 2001 From: Bukz Date: Sat, 16 Feb 2013 00:09:22 +0000 Subject: [PATCH] /loadcrosshair fixes/updates (plz review/test) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7211 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- config/docs.cfg | 9 +++++++-- source/src/protos.h | 12 +++++++++++- source/src/renderhud.cpp | 24 ++++++++++++++++++------ source/src/weapon.cpp | 2 +- 4 files changed, 37 insertions(+), 10 deletions(-) diff --git a/config/docs.cfg b/config/docs.cfg index 11908c88..dcd01f44 100644 --- a/config/docs.cfg +++ b/config/docs.cfg @@ -787,9 +787,14 @@ docident [listcomplete] []; docident [listdemos] [Get the game demos listing from the server we are currently connected.]; docident [listignored] [Print a list of all players that you are currently ignoring.]; docident [listmuted] [Print a list of all players that you have muted.]; -docident [loadcrosshair] [Loads a crosshair for a specific weapon of - if the weapon argument is omitted or <0 - for all weapons.]; +docident [loadcrosshair] [Loads a crosshair for argument T.]; docargument [I] [image] [] [0]; -docargument [W] [weapon] [-1,0..7] [0]; +docargument [T] [type] [all, scope, teammate, knife, pistol, carbine, shotgun, smg, sniper, ar, cpistol, grenades, akimbo] [0]; +docexample [loadcrosshair red_dot.png] [Loads the red_dot.png crosshair for all weapons.]; +docexample [loadcrosshair red_dot.png all] [Same as above. Loads the red_dot.png crosshair for all weapons.]; +docexample [loadcrosshair red_dot.png knife] [Loads the red_dot.png crosshair for your knife only.]; +docexample [loadcrosshair red_dot.png ar] [Loads the red_dot.png crosshair for your assault rifle only.]; +docexample [loadcrosshair red_dot.png scope] [Loads the red_dot.png crosshair for your sniper rifle scope only.]; docident [localfootsteps] [Indicates if the footsteps sound for the local player should be played]; docargument [B] [enable footsteps] [1 (true), 0 (false) min 0/max 1/default 1]; docident [magcontent] [Returns contents of current magazine.]; diff --git a/source/src/protos.h b/source/src/protos.h index a40abdb8..a6a4053d 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -270,7 +270,17 @@ enum CROSSHAIR_DEFAULT = 0, CROSSHAIR_TEAMMATE, CROSSHAIR_SCOPE, - CROSSHAIR_NUM + CROSSHAIR_KNIFE, + CROSSHAIR_PISTOL, + CROSSHAIR_CARBINE, + CROSSHAIR_SHOTGUN, + CROSSHAIR_SMG, + CROSSHAIR_SNIPER, + CROSSHAIR_AR, + CROSSHAIR_CPISTOL, + CROSSHAIR_GRENADES, + CROSSHAIR_AKIMBO, + CROSSHAIR_NUM, }; extern void drawcrosshair(playerent *p, int n, struct color *c = NULL, float size = -1.0f); diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 20cdf5af..ebaa0fdb 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -240,7 +240,7 @@ void drawscope(bool preload) glEnable(GL_BLEND); } -const char *crosshairnames[CROSSHAIR_NUM] = { "default", "teammate", "scope" }; +const char *crosshairnames[CROSSHAIR_NUM] = { "default", "teammate", "scope", "knife", "pistol", "carbine", "shotgun", "smg", "sniper", "ar", "cpistol", "grenades", "akimbo" }; Texture *crosshairs[CROSSHAIR_NUM] = { NULL }; // weapon specific crosshairs Texture *loadcrosshairtexture(const char *c) @@ -253,13 +253,25 @@ Texture *loadcrosshairtexture(const char *c) void loadcrosshair(char *c, char *name) { - int n = -1; - loopi(CROSSHAIR_NUM) if(!strcmp(crosshairnames[i], name)) { n = i; break; } - if(n<0) + if (strcmp(name, "") == 0 || strcmp(name, "all") == 0) { - n = atoi(name); - if(n<0 || n>=CROSSHAIR_NUM) return; + for (int i = 0; i < CROSSHAIR_NUM; i++) + { + if (i == CROSSHAIR_TEAMMATE || i == CROSSHAIR_SCOPE) continue; + crosshairs[i] = loadcrosshairtexture(c); + } + return; } + + int n = -1; + + for (int i = 0; i < CROSSHAIR_NUM; i++) + { + if(strcmp(crosshairnames[i], name) == 0) { n = i; break; } + } + + if (n < 0 || n >= CROSSHAIR_NUM) return; + crosshairs[n] = loadcrosshairtexture(c); } diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 4151f87c..a84ff1bb 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -907,7 +907,7 @@ void weapon::onselecting() } void weapon::renderhudmodel() { renderhudmodel(owner->lastaction); } -void weapon::renderaimhelp(bool teamwarning) { drawcrosshair(owner, teamwarning ? CROSSHAIR_TEAMMATE : CROSSHAIR_DEFAULT); } +void weapon::renderaimhelp(bool teamwarning) { drawcrosshair(owner, teamwarning ? CROSSHAIR_TEAMMATE : owner->weaponsel->type + 3); } int weapon::dynspread() { return info.spread; } float weapon::dynrecoil() { return info.recoil; } bool weapon::selectable() { return this != owner->weaponsel && owner->state == CS_ALIVE && !owner->weaponchanging; }