Commit Graph

278 Commits

Author SHA1 Message Date
Edoardo Prezioso 07c110d5f7 - Fixed GCC compilation error.
It didn't like 'cvar' being declared between 'goto foundit' and the 'foundit' label.
2016-11-30 19:41:03 +01:00
Christoph Oelckers 1895feb185 - fixed two apparently bogus asserts with returning gloating point constants. 2016-11-30 19:22:56 +01:00
Christoph Oelckers 83d7f63364 - missed these in the last commit. 2016-11-30 18:43:10 +01:00
Christoph Oelckers 86544086df - allow the VM to run on one global stack per thread.
It is utterly pointless to require every function that wants to make a VM call to allocate a new stack first. The allocation overhead doubles the time to set up the call.
With one stack, previously allocated memory can be reused. The only important thing is, if this ever gets used in a multithreaded environment to have the stack being declared as thread_local, although for ZDoom this is of no consequence.

- eliminated all cases where native code was calling other native code through the VM interface. After scriptifying the game code, only 5 places were left which were quickly eliminated. This was mostly to ensure that the native VM function parameters do not need to be propagated further than absolutely necessary.
2016-11-30 17:15:01 +01:00
Christoph Oelckers b0f3121bec - split up zscript/shared/inventory.txt.
- moved health items to their own file.
- scriptified ScoreItem and MapRevealer whose entire functionality was a small TryPickup method.
- fixed: bit fields in global variables were not correctly written.

This should conclude the inventory cleanup. It is now possible again to find things in there.
2016-11-30 13:36:13 +01:00
Christoph Oelckers 229c55ce61 - moved ammo to its own file, including the backpack.
- moved weapon declarations to their own header.
2016-11-30 12:24:50 +01:00
Christoph Oelckers 78fa076079 - moved armor class declarations to their own file and added necessary #includes only to those files actually using them.
- added copyright headers to a_armor.cpp and a_keys.cpp.
2016-11-30 10:55:03 +01:00
Christoph Oelckers b1910effd6 - remove debug code. 2016-11-30 09:54:37 +01:00
Christoph Oelckers 661692062d - fixed: FxIdentifier::Resolve checked all cases of what an identifier can be, even if it already found a proper match. 2016-11-30 09:53:16 +01:00
Christoph Oelckers a13e23dbe6 - scriptified some trivial stuff from g_shared. 2016-11-29 19:50:34 +01:00
Christoph Oelckers f17f6c30c2 - scriptified the Heresiarch. 2016-11-29 17:17:10 +01:00
Christoph Oelckers be5ba70ed2 - scriptified Strife's dagger and crossbow. 2016-11-29 13:00:07 +01:00
Christoph Oelckers 3af9232fca - scriptified a_strifeitems.cpp and a_debris.cpp.
- Changed the glass shards so that they do not have to override FloorBounceMissile. It was the only place where this was virtually overridden and provided little usefulness.
- made 'out' variables work.
- fixed virtual call handling for HandlePickup.
2016-11-29 12:17:05 +01:00
Christoph Oelckers edd8e51a69 - scriptified most of a_strifestuff.cpp. 2016-11-28 23:30:14 +01:00
Christoph Oelckers caef5344b0 - scriptified a_thingstoblowup.cpp.
- changed the power crystal floor movement to use DFloor instead of an incomplete in-place hack to ensure that everything is processed properly.
2016-11-28 21:33:14 +01:00
Christoph Oelckers 9064a5b0ac - scriptified Strife's coins.
- added a String class to allow attaching methods to the builtin string type. This works by checking if the left side of the member accessor is a string and just replacing the tyoe in this one place, all the rest is automatic.
2016-11-28 18:15:18 +01:00
Christoph Oelckers 8551a4f6e1 - scriptified the Sigil. This isn't fully tested yet. 2016-11-28 14:39:25 +01:00
Christoph Oelckers ebd2c27e0a - scriptified Hexen's Bloodscourge and Serpent.
- merged the FrontBlock searcher for the Bloodscourge into RoughMonsterSearch. This also fixes the bug that the searcher was not initialized properly for the MageBoss.
2016-11-28 00:49:10 +01:00
Christoph Oelckers de6969997a - scriptified Hexen's flies.
A few notes:

 * this accesses the lines array in sector_t which effectively is a pointer to an array of pointers - a type the parser can not represent. The compiler has no problems with it, so for now it is defined internally.
 * array sizes were limited to 65536 entries because the 'bound' instruction only existed as an immediate version with no provisions for larger values. For the static map arrays 65536 is not sufficient so now there are alternative instructions for these cases.
 * despite the above, at the moment there is no proper bounds checking for arrays that have no fixed size. To do this, a lot more work is needed. The type system as-is is not prepared for such a scenario.
2016-11-27 18:52:24 +01:00
Christoph Oelckers aab304c0cf - fixed: Lemon includes ParseTrace only in debug builds so the option to use it must be #ifdef'd. 2016-11-27 17:43:11 +01:00
Christoph Oelckers f409a24d2d - fixed: Readonly pointers never were flagged as such.
- fixed: Assignment from a readonly to a read-allowed pointer must be an error.
- made GetDefaultByType a builtin so that it can do proper type assignment to the result, which for a function would be problematic in this case, even if automatic type deduction was implemented. Since this returns the class defaults which are not a real object, the result cannot be subjected to a type cast.
- error out if a type cast of a readonly pointer is attempted.
- fixed: FxBooleanNot could clobber a local variable because it used the source register to manipulate the result.
2016-11-27 16:24:33 +01:00
Christoph Oelckers 3dd323ac0d - scriptified the Flechette. Not fully tested yet.
- fixed issues with the refactoring of the recent commits. This one starts again.
- added builtins for TextureID.

Note about builtins: Currently they are just hacked into the compiler backend. They really should be made part of the respective types to keep matters clean and allow more widespread use of builtins to create more efficient code.
2016-11-27 16:24:33 +01:00
Christoph Oelckers 36f559ecb7 - fixed bad definition of struct grammar which tried to resolve from right to left, creating large amounts of recursion and strange problems with PlayerInfo.
- added a command line option to generate a parser trace file.
- fixed a syntax error in player.txt.
2016-11-27 16:24:32 +01:00
Christoph Oelckers 096c51d546 - changed AInventory::HandlePickup to work iteratively instead of recursively.
Two reasons for this:

1. if this has to be routed through the VM each recursion will cost 1000 bytes of stack space which simply is not good.
2. having the virtual function only care about the item itself but not the entire inventory chain is a lot less error prone for scripting.

Since the scripting interface needs a separate caller function anyway this seemed like a good time to change it. The same will be done for the other chained inventory handlers as well.
2016-11-27 16:24:31 +01:00
Edoardo Prezioso 6eff1cb8be - Fixed more GCC/Clang warnings. 2016-11-27 02:34:32 +01:00
Christoph Oelckers 69d4d36429 - scriptified ArtiHealingRadius.
- allow switch/case with names.
- fixed break jump target handling for switch/case. This only worked when the break was in the outermost compound statement, those in inner ones were missed.
2016-11-27 00:18:07 +01:00
Christoph Oelckers 997e4a2ac4 - scriptified the remaining Cleric weapons. 2016-11-26 19:23:22 +01:00
Christoph Oelckers 177aa6ec42 - converted half of ClericHoly. (Making a commit before starting on the more complex stuff.)
- added a 'constructor' for color values.
2016-11-26 13:18:48 +01:00
Christoph Oelckers 7385cd70c0 - scriptified the Minotaur.
Interesting tidbit: The damage calculation in P_MinotaurSlam had been incorrect for the Heretic version since the friendly Hexen Dark Servant was added, but nobody ever noticed in 14 years...
2016-11-26 01:14:47 +01:00
Christoph Oelckers 53ff7f0c73 - fixed: Do not allow empty function arguments pass. For unknown reasons the grammar accepts them as valid, so this needs to be checked when resolving them. 2016-11-25 16:35:07 +01:00
Christoph Oelckers 8dba322775 - scriptified Heretic's Skull Rod.
- Took the opportunity and fixed the logic for the Skull Rod's rain spawner. The old code which was part of the 3D floor submission was unable to work with portals at all. The new approach no longer tries to hide the dead projectile in the ceiling, it leaves it where it is and changes a few flags, so that its z-position can be used as reference to get the actual ceiling. This works for line portals, but for sector portals still requires some changes to sector_t::NextHighestCeilingAt to work, but at least this can be made to work unlike the old code.
- added names for the player-related translations to A_SetTranslation.
- fixed: Failure to resolve a function argument was checked for, too late.
- made the parameter for A_SetTranslation a name instead of a string, because it is more efficient. We do not need full strings here.
2016-11-25 16:05:03 +01:00
Christoph Oelckers c2f7ed7f1c - fixed: BuiltinNameToClass should treat NAME_None as 'nothing'.
It's names that get here, after all, so the name for 'nothing' should actually mean 'nothing' here.
2016-11-25 12:45:17 +01:00
Christoph Oelckers 11ac0c622b - fixed: The BFG needs to get its default ammo usage from the DehInfo struct.
- fixed: State's fields need to be declared native.
2016-11-25 01:33:04 +01:00
Christoph Oelckers 66d28a24b8 - disabled the scripted virtual function module after finding out that it only works if each single class that may serve as a parent for scripting is explicitly declared.
Needless to say, this is simply too volatile and would require constant active maintenance, not to mention a huge amount of work up front to get going.
It also hid a nasty problem with the Destroy method. Due to the way the garbage collector works, Destroy cannot be exposed to scripts as-is. It may be called from scripts but it may not be overridden from scripts because the garbage collector can call this function after all data needed for calling a scripted override has already been destroyed because if that data is also being collected there is no guarantee that proper order of destruction is observed. So for now Destroy is just a normal native method to scripted classes
2016-11-25 00:25:26 +01:00
Christoph Oelckers 9ae272d753 - scriptified Heretic's blaster.
- scriptified all Effect functions of Fastprojectile's children
- implemented access to class meta data.
- added a VM instruction to retrieve the class metadata, to eliminate the overhead of the function call that would otherwise be needed.
- made GetClass() a builtin so that it can use the new instruction

Important note about this commit: Scriptifying CFlameMissile::Effect revealed a problem with the virtual function interface: In order to work, this needs to be explicitly enabled for each single native class that may be used as a base for a scripted class. Needless to say, this will end up way too much work, as there are over 100 native classes, excluding those which will be scriptified. But in order to fix the problem this partially broken state needs to be committed first.
2016-11-24 20:02:44 +01:00
Christoph Oelckers 3f5bf88d69 - scriptified Heretic's mace.
- fixed: FxAssignSelf did not the correct number of registers for vector operations.
- fixed a few asserts in vector2 instructions.
- turned the virtual AActor::HitFloor method into a flag MF7_SMASHABLE. The only use of this function was to kill Hexen's pottery when they hit the floor, and this looks like something that can be exposed to modders less clumsily.
2016-11-24 13:45:43 +01:00
Christoph Oelckers 3e890d182b - scriptified D'Sparil.
- added retrieval of defaults from an actor pointer.
2016-11-24 01:23:35 +01:00
Edoardo Prezioso cd919e72e1 - Don't null-check the ZCC_TreeNode 'this' pointer.
Compilers are allowed to simplify the 'this == nullptr' code block because it makes no sense in 'well-defined C++ code'.
2016-11-23 23:30:54 +01:00
Christoph Oelckers 7527141ad4 - fixed: The morph actors stored their required classes as names, not as class pointers.
This prevented any kind of error check on them.
Unfortunately, due to backwards compatibility needs, on DECORATE the missing class may not be fatal so a workaround had to be added to clear those bogus pointers later if they are discovered to be broken.
For ZScript, though, this will result in a compile error, which was the intention behind this change.
2016-11-23 22:34:17 +01:00
Christoph Oelckers 5e67cf79d3 - scriptified the Ironlich. 2016-11-23 21:26:59 +01:00
Christoph Oelckers 1a20a5b999 - scriptified A_PainShootSkull which was the last remaining bit in g_doom, so this directory is gone now. 2016-11-23 19:47:09 +01:00
Christoph Oelckers 0c95568d98 - exported native fields of several more classes. 2016-11-23 01:31:48 +01:00
Christoph Oelckers 46757ff8bf - exported the native fields of FState and FLevelLocals as well. 2016-11-23 00:35:06 +01:00
Christoph Oelckers 099b9970ef - added proper definitions for all exported native fields.
- synthesize native fields for all declared flags, not just for AActor.
2016-11-22 23:43:32 +01:00
Christoph Oelckers 980c986305 - allow defining native fields through scripts. Internally this only requires exporting the address, but not the entire field.
- added new VARF_Transient flag so that the decision whether to serialize a field does not depend solely on its native status. It may actually make a lot of sense to use the auto-serializer for native fields, too, as this would eliminate a lot of maintenance code.
- defined (u)int8/16 as aliases to the byte and short types (Can't we not just get rid of this naming convention already...?)
- exporting the fields of Actor revealed a few name clashes between them and some global types, so Actor.Sector was renamed to CurSector and Actor.Inventory was renamed to Actor.Inv.
2016-11-22 19:20:31 +01:00
Christoph Oelckers 03a02a2036 - updated copyrights in a few files. 2016-11-22 12:28:11 +01:00
Christoph Oelckers bbb0778fd4 - scriptified Chicken and Pig - not tested yet, because other things have priority. 2016-11-22 12:21:55 +01:00
Christoph Oelckers 3db712cd73 - fixed: Switch statement without a default jumped to the first first case label instead.
- removed placeholder code from scripted Marine.
2016-11-21 22:20:25 +01:00
Christoph Oelckers 135cfcf016 - implemented State as an actual native struct, so that its fields can be accessed from scripts.
- refactored state bitfield members into a flag word because the address of a bitfield cannot be taken, making such variables inaccessible to scripts.
- actually use PNativeStruct for representing native structs defined in a script.
2016-11-21 21:34:34 +01:00
Christoph Oelckers 6cc00e79a6 - made all internal struct types NativeStructs so that all variables of their types are made references. 2016-11-21 19:20:27 +01:00