Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 11-23-2011, 08:22 AM   #1
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Problems with "Realistic Simulated Bullets" (also: Think screws everything up)

Hey there!
I found that Dev Com page about realistic simulated bullets some days ago and wanted to implement it into my HL2 SP mod.
When I first ran it without a debugger and luxuries like that, everything went wrong as soon as I shot once ("hl2.exe has stopped working"). Thank Microsoft at least the debugger worked how it was suppossed to and I found out, that the crash was caused by the Think/ClientThink function.
When I removed all calls to SetNext(Client)Think it worked, but there were no bullet holes and shots released from any weapon didn't do damage (so I assume the shots weren't even created)
How come that a simple Think function screws everything up? I also tried to put something pointless into the function, like "__asm MOV eax, eax" or a single "return;", but every single call failed.
The code that is currently used is identical to the one on the Dev Com, so there is hardly a chance of a mistake from me.

Thanks in advance,
aVoX

PS: Shouldn't the shots even be created, when (Client)Think is not called?
aVoX is offline  
Reply With Quote
Old 11-23-2011, 10:06 PM   #2
JLea
 
Join Date: Oct 2010
Reputation: 1
Posts: 49
Think handles all the bullets moving through the air/being deleted so removing think would screw up everything, yes.
JLea is offline   Reply With Quote
Old 11-24-2011, 01:14 AM   #3
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Quote:
Originally Posted by JLea View Post
Think handles all the bullets moving through the air/being deleted so removing think would screw up everything, yes.
Actually it screws everything up when I do call Think. When I don't call it, there are no bullets, but at least the game doesn't crash.
aVoX is offline   Reply With Quote
Old 11-24-2011, 01:54 AM   #4
zombie@computer
 
Join Date: Aug 2008
Reputation: 416
Posts: 908
So it crashes between SetNextXThink and the Think() function, or does it crash within the think function?
zombie@computer is offline   Reply With Quote
Old 11-24-2011, 02:11 AM   #5
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Quote:
Originally Posted by zombie@computer View Post
So it crashes between SetNextXThink and the Think() function, or does it crash within the think function?
I am not sure about that. I didn't modify SetNextXThink at all, so it's the version that comes with a fresh 2007 mod. The funny thing is: It can't be the fault of the Think function, because when I put some pointless code like Msg(), return or whatever into it, it crashes too.
I think there is going wrong some serious stuff. When I'm in a debugging session, the debugger always stops at the liine 2046 in physics_main.cpp.
Statement:
Code:
CBaseEntity **list = (CBaseEntity **)stackalloc( sizeof(CBaseEntity *) * listMax );
I can tell you more in about 3 hours (free hour, yay!)
aVoX is offline   Reply With Quote
Old 12-03-2011, 02:40 PM   #6
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
OK, a little bump and some information.
What I found out
  • ClientThink is OK, the crash only happens with the server-side Think()
  • When debugging, the debugger stops at line 2046 in physics_main.cpp
    Code:
    CBaseEntity **list = (CBaseEntity **)stackalloc( sizeof(CBaseEntity *) * listMax );
  • I still have no clue why something would happen.
aVoX is offline   Reply With Quote
Old 01-04-2012, 08:28 AM   #7
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Another humble bump.
Sorry to annoy you, if I do...
aVoX is offline   Reply With Quote
Old 01-04-2012, 09:12 AM   #8
zombie@computer
 
Join Date: Aug 2008
Reputation: 416
Posts: 908
if listMax is of a legal value, then the only cause of a failing alloc i can think of is bad memory management elsewhere; Either you have allocated a lot of data on the stack instead of on the heap (int[5000000] instead of int* = new int[5000000]), or there are problems with buffer overflows, etc. due to mismatches in memory allocation and usesage. Unfortunately both are hard to track as Valve has cleverly overridden the new and delete operators.
zombie@computer is offline   Reply With Quote
Old 01-04-2012, 10:06 AM   #9
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Someone replied!

Apart from some VGUI gimmickry I didn't mess around with pointers on the heap or the stack. I even copied the exact same code (previously I had some custom calculations about surface penetration).
I'll make a new, totally clean mod later to check whether this is also happening with a 'maiden' mod project.
I'll post the results later.
aVoX is offline   Reply With Quote
Old 01-04-2012, 12:59 PM   #10
aVoX
 
Join Date: Feb 2010
Reputation: 9
Posts: 151
Alrighty.
I have deleted all custom bullet-simulating code and rewritten _EVERYTHING_ (4th time already?), and now it magically works :O
I have not a bit of a clue what the error was but it seems resolved now.
Thanks anyways to everyone
aVoX is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 09:11 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.