From 1e188aadbd79a9a58ac2f2a1fc4698e9e428d625 Mon Sep 17 00:00:00 2001 From: ac-stef Date: Thu, 26 Mar 2015 15:06:41 +0100 Subject: [PATCH] fix loadcrosshair --- config/defaults.cfg | 7 +++---- config/menus_settings.cfg | 4 ++-- source/src/renderhud.cpp | 12 ++++++++---- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/config/defaults.cfg b/config/defaults.cfg index d6d30de0..d2eb6e19 100644 --- a/config/defaults.cfg +++ b/config/defaults.cfg @@ -2,12 +2,11 @@ // Do not modify anything below, instead change settings in game, or add to autoexec.cfg name "unarmed" // Change your name! -loadcrosshair default.png // Choose another crosshair, see ./packages/crosshairs/ -loadcrosshair teammate.png teammate // Teammate crosshair. -loadcrosshair red_dot.png scope // Scope crosshair. +loadcrosshair default default.png // Choose another crosshair, see ./packages/crosshairs/ +loadcrosshair teammate teammate.png // Teammate crosshair. +loadcrosshair scope red_dot.png // Scope crosshair. skin_cla (rnd 4) // Change your look. skin_rvsf (rnd 6) -autoreload 1 // Reload the guns automatically by default. setfont default // Choose your font ofc_gamma_list = [] diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 2e6059ad..bdc44cbe 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -285,10 +285,10 @@ menuitem [Change crosshair... ] [ showmenu Crosshai menuitem [Change scope crosshair... ] [ showmenu [Scope crosshairs] ] newmenu Crosshairs -menudirlist "packages/crosshairs" png [ loadcrosshair (concatword $arg1 .png) ] 1 +menudirlist "packages/crosshairs" png [ loadcrosshair default (concatword $arg1 .png) ] 1 newmenu [Scope crosshairs] -menudirlist "packages/crosshairs" png [ loadcrosshair (concatword $arg1 .png) scope ] 1 +menudirlist "packages/crosshairs" png [ loadcrosshair scope (concatword $arg1 .png) ] 1 newmenu [Reset Binds] menuinit [ resetbindsyes = 0 ] // Ensures this menu works correctly. diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index 3477facd..87734591 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -254,8 +254,12 @@ Texture *loadcrosshairtexture(const char *c) void loadcrosshair(char *type, char *filename) { - int index = 0; - if(strchr(type, '.')) + int index = CROSSHAIR_DEFAULT; + if(!*filename) + { // special form: loadcrosshair filename // short for "loadcrosshair default filename" + filename = type; + } + else if(strchr(type, '.')) { // old syntax "loadcrosshair filename type", remove this in 2020 const char *oldcrosshairnames[CROSSHAIR_NUM + 1] = { "default", "teammate", "scope", "knife", "pistol", "carbine", "shotgun", "smg", "sniper", "ar", "cpistol", "grenades", "akimbo", "" }; index = getlistindex(filename, oldcrosshairnames, false, 0); @@ -267,9 +271,9 @@ void loadcrosshair(char *type, char *filename) { // new syntax with proper gun names index = getlistindex(type, crosshairnames, false, CROSSHAIR_DEFAULT); } - if(!crosshairs[CROSSHAIR_DEFAULT] && index == CROSSHAIR_DEFAULT) + if(index == CROSSHAIR_DEFAULT) { - loopi(CROSSHAIR_NUM) if(!crosshairs[i]) crosshairs[i] = loadcrosshairtexture(filename); + loopi(CROSSHAIR_NUM) if(i != CROSSHAIR_TEAMMATE && i != CROSSHAIR_SCOPE) crosshairs[i] = loadcrosshairtexture(filename); } else {