|
|||||||
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
![]() 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? |
|
|
|
|
|
#2 |
![]() 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.
|
|
|
|
|
|
#3 |
![]() Join Date: Feb 2010
Reputation: 9
Posts: 151
|
|
|
|
|
|
|
#4 |
![]() 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?
|
|
|
|
|
|
#5 | |
![]() Join Date: Feb 2010
Reputation: 9
Posts: 151
|
Quote:
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 ); |
|
|
|
|
|
|
#6 |
![]() Join Date: Feb 2010
Reputation: 9
Posts: 151
|
OK, a little bump and some information.
What I found out
|
|
|
|
|
|
#7 |
![]() Join Date: Feb 2010
Reputation: 9
Posts: 151
|
Another humble bump.
Sorry to annoy you, if I do... |
|
|
|
|
|
#8 |
![]() 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.
|
|
|
|
|
|
#9 |
![]() 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. |
|
|
|
|
|
#10 |
![]() 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
|
|
|
|
![]() |
|
||||||
| Thread Tools | |
| Display Modes | |
|
|