Commit Graph

176 Commits

Author SHA1 Message Date
Christoph Oelckers fad406c4c9 - got rid of FNameNoInit and made the default constructor of FName non-initializing.
This setup has been a constant source of problems so now I reviewed all uses of FName to make sure that everything that needs to be initialized is done manually.
This also merges the player_t constructor into the class definition as default values.
2018-08-19 08:19:19 +02:00
Marisa Kirisame 02926a5567 Add "IsFinal" parameter for CheckReplacement.
If set to true it guarantees that the replacement is final and will not go through the rest of the replacement chain.
2018-08-16 21:44:21 +02:00
Marisa Kirisame e18b17217f Added CheckReplacement to event handlers, a function inspired by its namesake in Unreal's Mutator class.
Performs runtime replacement of actor classes.
Takes priority over the "replaces" keyword in both DECORATE and ZScript.
2018-08-15 19:31:09 +02:00
alexey.lysiuk 4d35b12808 - fixed crash on accessing state owner during VM abort
https://forum.zdoom.org/viewtopic.php?t=61338
2018-07-19 13:38:49 +03:00
alexey.lysiuk 2ae8d39441 Removed all superfluous #include's
Automatically optimized by CLion IDE with manual corrections
2018-04-24 14:30:35 +03:00
alexey.lysiuk 274951839a Removed unused parameter from several functions in FStateDefinitions class
src/p_states.cpp:724:54: warning: parameter ‘actor’ set but not used [-Wunused-but-set-parameter]
https://forum.zdoom.org/viewtopic.php?t=58364
2017-11-05 15:20:25 +02:00
alexey.lysiuk 65966badb2 Fixed crash on attempt to register IDs for undefined class
https://forum.zdoom.org/viewtopic.php?t=46670&start=16#p1021785
2017-10-07 16:30:49 +03:00
alexey.lysiuk c681d6eff0 Fixed applying of multiple pain chances
https://mantis.zdoom.org/view.php?id=608
2017-04-20 22:09:18 +03:00
alexey.lysiuk 490fd8f3a0 Fixed applying of multiple damage factors
https://mantis.zdoom.org/view.php?id=586
2017-04-15 12:33:26 +03:00
Christoph Oelckers 98dab9c4b9 - took PTypeBase and all its subclasses out of the DObject hierarchy.
- moved scope flag to a new variable that is specific to PType instead of hijacking the ObjectFlags for this.
2017-04-13 17:47:17 +02:00
Christoph Oelckers 988fe8d735 - removed all RTTI from the type table.
Using names is just as good as using types so now this is what's done.
2017-04-13 16:01:38 +02:00
Christoph Oelckers b2d944974e - first stage of simplifying the type system.
Let's use inline checkers in PType instead of constantly having to do clumsy IsKindOf checks etc. Once complete this also means that the types can be taken out of the class hierarchy, freeing up some common names.
2017-04-13 12:52:18 +02:00
alexey.lysiuk 1889efa814 Fixed build with Clang
Fixed bunch of compilation errors:
cannot pass non-trivial object of type 'FString' to variadic method; expected type from format string was 'char *' [-Wnon-pod-varargs]

Fixed linker erorr:
g_doomedmap.cpp.o: In function `InitActorNumsFromMapinfo()':
src/g_doomedmap.cpp: undefined reference to `PClass::FindActor(FName)'
2017-04-13 10:40:43 +03:00
Christoph Oelckers 6599e2c425 - moved the VM types into their own file and only include it where really needed. 2017-04-13 01:12:04 +02:00
Christoph Oelckers fc9e304189 - separated class descriptors from VM types.
Combining these two groups of data has been the cause of many hard to detect errors because it allowed liberal casting between types that are used for completely different things.
2017-04-12 22:46:49 +02:00
Christoph Oelckers 63eb3e331e - un-const-ify some functions. 2017-04-12 14:40:29 +02:00
Christoph Oelckers 80801d11b1 - removed some redundant static_casts. 2017-04-12 10:29:04 +02:00
Christoph Oelckers 5350721ec5 - removed PClass::DeriveData because it is no longer needed.
- fixed: IsVisibleToPlayer and optimized it a bit more.
- moved SourceLumpName to PClass, so that it can also be used for non-actors (there's a lot of non-Actor classes already.)
- separated the serializer for PClassPointer from PPointer. Even though not doable, a pointer to a class type is something entirely different than a class pointer with a restriction so each should handle its own case.
2017-04-12 09:55:27 +02:00
Christoph Oelckers e4d2380775 - moved all remaining fields from PClassActor to FActorInfo.
- added a few access functions for FActorInfo variables.

With PClassActor now empty the class descriptors can finally be converted back to static data outside the class hierarchy, like they were before the scripting merge, and untangle the game data from VM internals.
2017-04-12 00:07:41 +02:00
Christoph Oelckers 854053a14f - use TArrays instead of TMaps to store damage factors and pain chances.
For these fields maps have no advantage. Linearly searching a small array with up to 10 entries is nearly always faster than generating a hash for finding the entry in the map.
2017-04-11 23:29:37 +02:00
Christoph Oelckers 4afe2d4218 - moved OwnedStates and NumOwnedStates out of PClassActor. 2017-04-11 22:44:35 +02:00
Christoph Oelckers 05240ccbe5 - fixed redundant reallocation of constructable meta fields.
- some optimization of access to OwnedStates in old DECORATE.
- consolidate all places that print a state name into a subfunction.
- allocate states from the ClassDataAllocator memory arena. States do not need to be freed separately from the rest of the static class data.
2017-04-11 21:48:41 +02:00
Christoph Oelckers 311ce2362a - started moving stuff out of PClassActor into meta data.
This reinstates the old FActorInfo as part of the meta data a class can have so that the class descriptor itself can be freed from any data not directly relevant for managing the class's type information.
2017-04-11 19:37:56 +02:00
Christoph Oelckers 6a3ddaa8fa - moved Restricted/ForbiddenToPlayerClass fully to the script side.
This required some fixes for allowing to read from metadata arrays.
2017-04-11 15:11:13 +02:00
Christoph Oelckers 45691e91c9 - removed PClassActor::PointerSubstitution.
This is not needed anymore because classes do not need to be replaced. The only reason this was implemented was the original design with the class descriptors taking on all the metadata themselves.
2017-04-11 14:03:49 +02:00
Christoph Oelckers 60dd58e7d2 - most ATAG stuff is gone, except for the static storage space in the VMFunction. 2017-04-10 16:06:18 +02:00
Christoph Oelckers 00dc59ebdc - separated the blood translation index from the BloodColor variable to allow more than 255 blood translations and as a prerequisite for allowing to change the blood color. 2017-03-02 10:26:23 +01:00
Christoph Oelckers fc125f7eaf - reworked the obituary system to use scripted virtual overrides. Let's hope this solves the problems with the original code, now that any actor needing special treatment can override it. 2017-02-28 14:30:14 +01:00
Christoph Oelckers 851984efe0 - made GetDeathHeight a virtual scripted function.
- made GetGibHealth a virtual scripted function.
- removed a few more native meta properties.
2017-02-28 13:40:46 +01:00
Christoph Oelckers d5250d6b9f - made WoundHealth modifiable to allow more control over the wound state. 2017-02-28 12:56:35 +01:00
Christoph Oelckers 2a4a5e7a70 - refactored a few more native meta properties. 2017-02-28 12:47:44 +01:00
Christoph Oelckers 1311f08f47 - scriptified Actor.GetBloodType as a virtual function to allow mods more flexibility here.
- made CameraHeight a modifiable actor property - it was readonly before.
- allow accessing the type constants from ZScript, this required quite a bit of explicit coding because the type system has no capabilities to search for basic types by name.
2017-02-28 12:11:25 +01:00
Christoph Oelckers b6a1fe7fc6 - scriptified the basic attack functions, its properties and the explosion properties to test the new metadata system. 2017-02-28 10:51:32 +01:00
Christoph Oelckers 78a66e001a - properly handle all meta properties for inventory items. 2017-02-28 00:45:16 +01:00
Christoph Oelckers 321c846d01 - added StealthAlpha actor property for defining a minimum visibility value of a stealth monster. 2017-02-27 19:46:27 +01:00
Christoph Oelckers 78538ed9ef - missed an else. 2017-02-27 14:53:39 +01:00
Christoph Oelckers f9f9f2d5fc - added selfdamagefactor actor property. 2017-02-27 11:22:51 +01:00
Christoph Oelckers 3d500f0495 - added default obituaries for damage types.
Note that this is only implemented for the new official way of doing this in MAPINFO, but not in DECORATE!
2017-02-26 21:36:06 +01:00
Christoph Oelckers 2234d36c7a Merge branch 'thereisnospoon' of https://github.com/jewalky/gzdoom
# Conflicts:
#	src/dobject.h
2017-02-14 19:10:02 +01:00
Christoph Oelckers 8277299135 - Turned DropItem into a plain struct again like it was before the scripting branch got merged.
Making this an object had little to no advantage, except being able to remove the deleter code. Now, with some of the class data already being allocated in a memory arena so that freeing it is easier, this can also be used for the drop item lists which makes it unnecessary to subject them to the GC. This also merges the memory arenas for VM functions and flat pointers because both get deleted at the same time so they can share the same one.
2017-02-08 20:37:22 +01:00
Christoph Oelckers 17a2666bd4 - moved DisplayName, the last remaining PlayerPawn meta property, to PClassActor so that PClassPlayerPawn could be removed.
Now all actors have the same metaclass and therefore it will always be the same size which will finally allow some needed changes to the type system which couldn't be done because it was occasionally necessary to replace tentatively created classes due to size mismatches.
2017-02-08 19:42:24 +01:00
Christoph Oelckers c77f6636f8 - moved the three remaining variables from PClassInventory to PClassActor so that PClassInventory can be removed. 2017-02-08 18:11:23 +01:00
Christoph Oelckers a6785afddb - optimized the FName versions of IsDescendantOf and IsKindOf. These can be done without first looking up the class type itself. 2017-02-08 15:47:22 +01:00
Christoph Oelckers 3cbd62479b - took VMFunction out of the DObject hierarchy.
As it stood, just compiling the internal ZScript code created more than 9000 DObjects, none of which really need to be subjected to garbage collection, aside from allowing lazy deallocation.
This puts an incredible drag on the garbage collector which often needs several minutes to finish processing before actual deletion can start.

The VM functions with roughly 1800 of these objects were by far the easiest to refactor so they are now. They also use a memory arena now which significantly reduces their memory footprint.
2017-02-08 11:13:41 +01:00
Christoph Oelckers 776509e68a - let skip_super use the AActor assignment operator. The blanket memcpy it used was clobbering some data.
- moved the Finalize method from PClassActor to AActor. Now that defaults get their vtbl pointer initialized this will actually work.
2017-02-07 18:12:59 +01:00
ZZYZX efb1e5d33a Implemented global EventHandlers in MAPINFO 2017-01-23 20:48:57 +02:00
Christoph Oelckers 3148496f57 - scriptified BasicArmor and fixed a few errors in the conversion. 2017-01-18 22:15:48 +01:00
Christoph Oelckers 40e7fa5be2 - scriptified the RandomSpawner.
- fixed: String constants were not processed by the compiler backend.
- added an explicit name cast for class types.
2017-01-14 02:05:52 +01:00
Christoph Oelckers b3783a3850 redid the exception mechanism for script-side access violations to be of more use for diagnosing problems.
The original implementation just printed a mostly information-free message and then went on as if nothing has happened, making it ridiculously easy to write broken code and release it. Changed it to:

* Any VMAbortException will now terminate the game session and go back to the console.
* It will also print a VM stack trace with all open functions, including source file and line numbers pointing to the problem spots. For this the relevant information had to be added to the VMScriptFunction class.

An interesting effect here was that just throwing the exception object increased the VM's Exec function's stack size from 900 bytes to 70kb, because the compiler allocates a separate local buffer for every single instance of the exception object.
The obvious solution was to put this part into a subfunction so that it won't pollute the Exec function's own stack frame. Interesting side effect of this: Exec's stack requirement went down from 900 bytes to 600 bytes. This is still on the high side but already a lot better.
2016-12-03 12:23:13 +01:00
Christoph Oelckers 87484950cf - removed an assert from APowerMorph::EndEffect. With some recent changes to DestroyAllInventory it appears that the asserted condition no longer is true at this point when ending a game.
- fixed: When replacing a tentative class, the pointers in the morph objects were not replaced. Instead of adding more ReplaceClassRef methods I chose to integrate this part into the PointerSubstitution mechanism and delete ReplaceClassRef entirely. The code had some oversights anyway that would have caused problems, now that non-actors can be created.
2016-12-01 00:05:23 +01:00