-
Notifications
You must be signed in to change notification settings - Fork 11
Mapbase v8.0 in E:Z2 #345
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: ez2/mapbase
Are you sure you want to change the base?
Mapbase v8.0 in E:Z2 #345
Conversation
On every save on a load, these functions would keep reference to their old versions from the previous save which kept stacking up on each load-save
When a Vector or QAngle rvalue reference is returned from a VScript function, the constructed ScriptVariant_t must not store the pointer to it since it is, per convention, a temporary reference. Only do that for lvalue-references, but do a copy when constructing from or assigning a rvalue reference.
Type FIELD_HSCRIPT is removed, it never sets SV_FREE. All dynamic memory is now free`d via free(). For strdup(), this would be the conformant way in standard C++. It matters not in Source, since both use the same global allocator of the engine, but it is tidier. Vector and QAngle are now allocated via malloc() instead of new to provide symmetry.
When assigning a null value in getVariant(), make sure a previous SV_FREE is not carried over. In SqurrelVM::ReleaseValue(), make sure SV_FREE is not kept after Free()ing a value.
Instead of temporary allocating dynamic memory, which subsequently is copied into another dynamically allocated piece of memory, provide a temporary buffer on the stack. The script value inserted into the VM still needs to allocate dynamically though... A few sites are adapted to not create a ScriptVariant_t from a temporary Vector to avoid dynamic allocation there too. cf. mapbase-source#321
They wouldn't even work.
Free values before assignment.
They were broken, and only add for Quaternions was implemented, for which there is a working QuaternionAdd() script function instead. Fixing it seems like unnecessary work.
… has userpointer type This prevents memory errors when incorrectly invoking native member functions from Squirrel.
…on call This enhances the ScriptFuncDescriptor_t to record the ScriptClassDesc_t of the class for which it gets invoked. The ScriptClassDesc_t are traversed in the function_stub() for native function calls for member functions, to ensure the passed in instance has a compatible type. This prevents memory errors when incorrectly invoking native member functions from Squirrel.
This prevents manual invocations of the Vector.constructor with an invalid value.
…meters This prevents manual invocations of the native class constructor for non-class values or non-native classes.
This prevents manual invocations of the native class constructor with an invalid value.
The function_stub() resets it when used.
Also streamline SQUserPointer usage in sq_getinstanceup() and sq_getuserpointer() calls to write directly to a pointer of the expected type.
This fixes a memory leak.
…on-call-safety VScript member function call safety
vscript saverestore and debugger fixes
…etset-fallback Fallback if IScriptInstanceHelper::Get/Set are not implemented
…-2013 into ez2/feature/mapbase-v8.0 # Conflicts: # sp/src/game/server/hl2/hl2_player.cpp # sp/src/game/server/hl2/item_battery.cpp # sp/src/game/server/hl2/npc_antlion.cpp # sp/src/game/server/hl2/npc_attackchopper.cpp # sp/src/game/server/hl2/npc_combine.h # sp/src/game/server/hl2/npc_fastzombie.cpp # sp/src/game/server/hl2/npc_zombie.cpp # sp/src/game/server/hl2/npc_zombine.cpp # sp/src/game/shared/ai_responsesystem_new.cpp # sp/src/game/shared/hl2/basehlcombatweapon_shared.cpp # sp/src/game/shared/hl2/basehlcombatweapon_shared.h # sp/src/game/shared/mapbase/mapbase_shared.cpp
c2a48f1 to
98b3f75
Compare
| if (pPlayer) | ||
| { | ||
| if (pPlayer->DrawingPlayerModelExternally() && pPlayer->InFirstPersonView()) | ||
| return false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this change the behavior of muzzle flashes in EZ2? I know that in EZ and EZ2 muzzle flashes create a d-light to light up the surroundings and I think this applies to the player as well. I also remember working on projected texture based muzzle flashing lighting for the player but I cannot remember if we finished that or not.
| textParams.b1 = 255; | ||
|
|
||
| if (ai_speech_print_mode.GetBool() && GetOuter()->GetGameTextSpeechParams( textParams )) | ||
| if (ai_speech_print_mode.GetBool() && GetOuter()->DispatchGetGameTextSpeechParams( textParams )) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you happen to know what this change does? I'm curious
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GetGameTextSpeechParams is used to get a NPC's speech params, and by default it can be overridden by VScript to have custom parameters. However, GetGameTextSpeechParams is also a virtual function which can be overridden by derived classes, and this overrides the VScript hook. This was a problem when I tried to use VScript to override the text params of Bad Cop or NPCs. To fix this without breaking existing overrides, I made the functions that display the text call a new DispatchGetGameTextSpeechParams function which checks for the VScript hook before using the overridable GetGameTextSpeechParams.
You can see more about this change in baseflex.cpp/.h, where the function is implemented.
This pull request merges Mapbase v8.0 into E:Z2. This includes several features which are needed for some currently open PRs and are critical for Progenitors.
I've tested most of these features in E:Z2 locally in the past, but this particular merge had a lot of conflicts and I haven't tested it directly yet.