Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » Can you spot the glitch?  () 1 Vote
Re: Can you spot the glitch? [message #485639 is a reply to message #485624] Tue, 04 February 2014 05:30 Go to previous messageGo to previous message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma:
General (5 Stars)
You should fix the following problems;


GameObject* checkplayerobj = Commands->Find_Object(number);

if ( IsInsideZone(obj,checkplayerobj))


You passed <number> as a timer parameter, so at this point you don't know that the gameobject referenced by that number still exists. Your code will crash if checkplayerobj is NULL after the call to Find_Object. Change it to

GameObject* checkplayerobj = Commands->Find_Object(number);

if ( NULL != checkplayerobj && IsInsideZone(obj,checkplayerobj))






const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (strcmp(currentweapon, i) == 0 && Get_Current_Bullets(checkplayerobj) > 0) 


NULL is a valid return value from Get_Current_Weapon, again leading to a potential crash. Fix it by checking for NULL before using currentweapon

const char* currentweapon = Get_Current_Weapon(checkplayerobj);
if (NULL != currentweapon && strcmp(currentweapon, i) == 0 && Get_Current_Bullets(checkplayerobj) > 0) 


Also fix this in your Remove_Weapon_Safely function (which doesn't appear to be called anywhere?)





Commands->Select_Weapon(checkplayerobj,"");
Commands->Select_Weapon(checkplayerobj,i);



This would appear to be redundant, why call Select_Weapon twice?





http://steamsignature.com/card/1/76561197975867233.png
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: level edit strings are gone!
Next Topic: CnC 95 DOS sidebar (WIP)
Goto Forum:
  


Current Time: Wed Dec 18 09:55:34 MST 2024

Total time taken to generate the page: 0.00690 seconds