Commit graph

7402 commits

Author SHA1 Message Date
Christoph Oelckers
b0ddba2240 Merge branch 'master' of c:\Programming\Doom-Dev\zdoom_\ into zscript 2016-11-27 16:31:26 +01:00
Christoph Oelckers
2e99681ced - fixed: When trying to calculate the damage for a blasted actor hitting another one, the velocity checks used the signed values, causing totally random damaging effects depending on the direction the objects were moving. This bug had been present in the original Hexen source as well. 2016-11-27 16:26:31 +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
b10ffb5133 - exported a few more functions.
- refactored the ModifyDamage interface to be more scripting friendly.

In general it should be avoided having to call directly into chained inventory functions because they are very problematic and prone to errors. So this got wrapped into a single handler (on AActor, not AInventory!) which will later make it easier to refactor the parameters of ModifyDamage to work better for scripting and avoid the chaining.
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
Magnus Norddahl
6417c1a7a3 Rewrite PrepWall and PrepLWall, plus make them aware of pixel centers 2016-11-27 00:43:32 +01:00
Christoph Oelckers
ab03b016e9 - scriptified the IceGuy. 2016-11-27 00:41:06 +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
Magnus Norddahl
547973c8ba Rewrite OWallMost and WallMost to contain no build code 2016-11-26 23:28:21 +01:00
Christoph Oelckers
796c262285 - scriptified the Quietus. 2016-11-26 23:05:16 +01:00
Christoph Oelckers
80f233cd0b - scriptified the fighter's fist. 2016-11-26 22:25:49 +01:00
Christoph Oelckers
178db4bb09 - scriptified the fighter's hammer. 2016-11-26 21:39:20 +01:00
Christoph Oelckers
bdad526f62 - scriptified the Fighter's axe. 2016-11-26 21:03:00 +01:00
Christoph Oelckers
e541c27622 - scriptified the weapon's state getter methods - as preparation for the fighter axe. 2016-11-26 19:48:30 +01:00
Christoph Oelckers
997e4a2ac4 - scriptified the remaining Cleric weapons. 2016-11-26 19:23:22 +01:00
Christoph Oelckers
659a592f16 - scriptified Korax. 2016-11-26 16:25:10 +01:00
Christoph Oelckers
4fcb397346 - scriptified the remaining parts of the Wraithverge. 2016-11-26 14:06:41 +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
bc1e4eff72 - scriptified the Cleric's flame weapon. Also fixed the angle calculations for the circle flame. 2016-11-26 10:30:41 +01:00
Christoph Oelckers
f508a57bb8 - scriptified ArtiBoostArmor. 2016-11-26 10:08:25 +01:00
Christoph Oelckers
4e802652c7 - scriptified ArtiBlastRadius. 2016-11-26 09:51:14 +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
6e1c6c4b33 - scriptified ArtiTeleport.
- shortened ArtiEgg and ArtiPork's use state to a single function.
2016-11-25 19:52:35 +01:00
Christoph Oelckers
0d6f37835f - completed Heretic scriptification with the two remaining artifacts. 2016-11-25 18:41:00 +01:00
Christoph Oelckers
4f370ba181 - scriptified the Phoenix Rod, completing the Heretic weapons. 2016-11-25 18:13:08 +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
82e5e2daa9 - fixed a variable mixup in Dehacked weapon initialization.
This ultimately failed to set the weapon's AmmoUse field and made the weapon fail to detect it's out of ammo.
2016-11-25 12:31:13 +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
677d7579d4 - scriptified Heretic's crossbow and gauntlets. 2016-11-24 11:29:51 +01:00
Christoph Oelckers
2ece9b6172 - scriptified Heretic's staff and wand. 2016-11-24 10:39:16 +01:00
Edoardo Prezioso
ae382f4005 - Fixed the spline/cubic crashes for FMOD 4.24 64-bit, too. 2016-11-24 09:26:39 +01:00
Edoardo Prezioso
68dc3c4f2d - Preventive fix for future include conflicts.
basicinlines.h is only included in m_fixed.h, while basictypes.h is included only in headers, so it's better to respect this convention. OSX compiles fine also without m_fixed.h, even better.
2016-11-24 09:09:09 +01:00
Braden Obrzut
dc11b63157 - Fixed building with vanilla MinGW, at least with whatever modified header files that my system has from my last experimentation. 2016-11-24 00:47:53 -05: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
8a7671ad8b - exported all member fields from the morph items.
- renamed APowerMorph::Player to avoid accidental confusion with AActor::player, which in scripting is the same due to case insensitvity.
- renamed save key for above variable.
2016-11-23 23:28:03 +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
f8c6adb7eb - completely redid how A_PainShootSkull checks the legality of the LS spawn.
It turned out that the Boom method does not work well with portals and fixing it while keeping it doesn't look feasible - the entire approach was bad from the start.
Instead, let's use the same approach as P_XYMovement: Spawn the Lost Soul at the center of the PE, and then use multiple P_TryMoves to get it to its intended location.
This will check all blocking lines, just like Boom did, but it will also properly handle z-positioning and portal transitions.
2016-11-23 18:54:16 +01:00
Christoph Oelckers
7325e3f0f8 - exported all member fields that make sense. Entirely private ones or classes that are not supposed to be extended were left out. 2016-11-23 17:34:36 +01:00
Christoph Oelckers
d1f5d916c2 Merge branch 'master' into zscript 2016-11-23 14:39:14 +01:00
Christoph Oelckers
9bd19c2d2e - ensure that the MAPINFO parser never mixes HexenHack parsing with the new format. 2016-11-23 14:38:45 +01:00
alexey.lysiuk
e138a3ffbc Fixed infinite recursion with self-referencing multipatch textures
See http://forum.zdoom.org/viewtopic.php?t=54355
2016-11-23 14:33:31 +01:00
Christoph Oelckers
5b059971f0 - fixed: P_SpawnMapThing forced gravity instead of disabling it when being given Gravity = 0 from UDMF. 2016-11-23 14:32:18 +01:00
Christoph Oelckers
6ae266c76e - fixed: The check for identical floor planes on an opening should never allow it to be narrowed down.
This can cause problems in rare situations where a sloped plane is checked outside its sector boundaries.
2016-11-23 14:27:08 +01:00
Edoardo Prezioso
0489b6e7c5 - Fixed missing newlines to the conversation error message. 2016-11-23 10:19:52 +01:00
Christoph Oelckers
649c96261a - clarified error messages for bogus conversation scripts. 2016-11-23 10:13:50 +01:00
Braden Obrzut
789315bb4a - Fixed build with MinGW-w64 (TDM-GCC 5.1). Note that the resulting binary will crash under -O3 until the alignment violation is taken care of in FRemapTable::Alloc.
- It appears that CMake added native support for building rc files with MinGW at some point so removed manual rc compiling code.
2016-11-22 22:41:32 -05: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
Edoardo Prezioso
e1c4e4939a - Fixed the order of the MS sections. 2016-11-22 21:20:42 +01:00
Edoardo Prezioso
e2167c661c - Fixed GCC/Clang compile errors. 2016-11-22 21:16:13 +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
ab5c11064a - added a few missing tildes. 2016-11-22 13:03:46 +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
ff3baac8a7 - made PStatePointer a real pointer pointing to a native struct named 'state', because that's what it really is and what it needs to be if we want to use a state as more than an opaque identifier in the VM 2016-11-21 19:36:14 +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
Christoph Oelckers
360436c201 - scriptified the scripted marines.
- fixed symbol name generation for native functions.
- moved PrintableName to VMFunction so that native functions also have this information.
2016-11-21 19:09:58 +01:00
Christoph Oelckers
97763b5a2b - added scriptable virtual overrides for PostBeginPlay, Tick, BeginPlay, Activate and Deactivate. 2016-11-21 14:59:17 +01:00
Christoph Oelckers
7d99552903 - added two new integral types SpriteID and TextureID, both are needed to allow proper serialization as they require something different to be written out than a regular integer. 2016-11-21 13:45:33 +01:00
Christoph Oelckers
de2eb18727 - added per-channel access for color variables. However, since they are locally stored in registers, it required a minor bit of fudging for this case.
- make sure that a PFunction's implementation is always initialized before starting the code generator.
2016-11-21 12:38:39 +01:00
Christoph Oelckers
393bcf9e91 - extended ExpEmit::RegNum to 16 bits so that it can hold larger values for constant registers. 2016-11-21 10:50:09 +01:00
Christoph Oelckers
188c0ee932 - removed the REGT_NIL check from the PARAM_EXISTS macro, because with the implemented handling of named arguments it isn't possible that REGT_NIL can end up in the parameters without a programming error.. 2016-11-21 10:28:06 +01:00
Kyle Evans
3270b20045 Remove non-existant source file 2016-11-20 21:33:23 -06:00
Christoph Oelckers
e7f6bae83e - implemented named arguments.
- fixed flag CVAR access. As it turned out, OP_LBIT is a bit messy to set up properly when accessing integers that may or may not be big endian, so it now uses a shift and bit masking to do its work.
- used the SpawnPlayerMissile call in A_FireBFG to test named arguments.
2016-11-21 01:32:01 +01:00
Christoph Oelckers
7d8143224e - restored two accidentally deleted VM instructions. 2016-11-21 00:33:55 +01:00
Christoph Oelckers
8f722a3633 - fixed: FxCVar must free its address register. 2016-11-20 23:26:32 +01:00
Christoph Oelckers
e93961da96 - removed all constant versions of vector instructions. The vector code does not use compound constants so there's no need to have instructions for them.
- fixed: The code generator had no good safeguards for exceeding the maximum amount of registers.

All there was was a handful of pitiful asserts which in production code do nothing at all but generate broken output.
Even worse, the VM was hardwired to at most 255 constants per type per function by storing the constant count in a byte! This has been extended to 65535, but since many instructions only have a byte available for the constant index, a workaround had to be added to do a two-instruction setup if larger indices are needed.
2016-11-20 23:00:05 +01:00
Christoph Oelckers
1c2c26eb08 - implemented direct CVar access. 2016-11-20 20:24:39 +01:00
Christoph Oelckers
5951a9449c - added static constant arrays. At the moment they can only be defined inside functions due to lack of dedicated storage inside classes for static data.
- added new VM instructions to access the constant tables with a variable index.
- refactored VMFunctionBuilder's constant tables so that they are not limited to one entry per value. While this works fine for single values, it makes it impossible to store constant arrays in here.
2016-11-20 18:00:37 +01:00
Christoph Oelckers
bb25c5faaa - scriptified the remaining Doom weapon code.
- implemented method calls from struct instances.
- optimized disassembly of VM call instructions to print the function's name at the end where it is more visible and does not need to be truncated. Also use the printable name for script functions here.
2016-11-20 12:27:26 +01:00
Christoph Oelckers
ab6b2f369e - fixed: For varargs, not only the type but also the flag of the last specified argument need to be stored for later parameters. 2016-11-20 09:47:46 +01:00
Christoph Oelckers
3c726aa570 - scriptified A_FirePlasma. 2016-11-20 01:18:21 +01:00
Christoph Oelckers
fdab994fcb - scriptified the Rocket launcher. 2016-11-20 01:11:01 +01:00
Christoph Oelckers
814493b68d - scriptified the Super Shotgun. 2016-11-20 00:45:06 +01:00
Christoph Oelckers
af34d82888 - scriptified A_Saw.
- implemented multiple-return-value assignment. Due to some grammar conflicts the originally intended Lua-inspired syntax of 'a, b = Function()' could not be done, so it's '[a, b] = Function()'
2016-11-20 00:25:38 +01:00
Christoph Oelckers
74c5659fc5 - explicitly call Destroy in PClass::StaticShutdown because some class type objects were no longer automatically collected. 2016-11-19 18:09:34 +01:00
Christoph Oelckers
7595343aaa - fixed: Completely empty if statements left the code generator in a broken state. 2016-11-19 18:02:07 +01:00
alexey.lysiuk
c28bcca3f3 Print unknown if release information is unavailable on macOS
At least 10.4 Tiger doesn't support required sysctl name
2016-11-19 16:42:16 +01:00
alexey.lysiuk
60ac12be0a Fixed compilation warnings in Cocoa backend 2016-11-19 16:42:16 +01:00
alexey.lysiuk
3b240b73e9 Fixed endianness issue with saved games
See http://forum.zdoom.org/viewtopic.php?t=54272
2016-11-19 16:42:16 +01:00
Christoph Oelckers
0b70df88d8 - scriptified A_FireShotgun and A_FireChaingun. 2016-11-19 16:39:45 +01:00
Christoph Oelckers
d50da34664 - scriptified the pistol to test if struct member functions work.
- made APlayerPawn::PlayAttacking(2) virtual script functions so that mods have better control over player animations. Note that these have no native base so they skip the templated interface for managing virtual functions.
2016-11-19 13:56:29 +01:00
Christoph Oelckers
de8cacc465 - for struct member calls an address request is needed. 2016-11-19 12:41:00 +01:00
Christoph Oelckers
25e285b65d - fixed bad conversion from FString to const char * in state label type cast. 2016-11-19 12:25:53 +01:00
Christoph Oelckers
9fab8380ff - fixed: FxVMFunctionCall::GetDirectFunction did not check if the function could be called with no arguments. 2016-11-19 12:22:58 +01:00
Christoph Oelckers
f11f020b6c - allow functions in structs. This is needed for several internal data types like players, sectors, lines, etc.
- added a new type 'NativeStruct'. This will be used for types that cannot be instantiated, and is also needed to cleanly handle many internal types that only can exist as reference.
2016-11-19 12:12:29 +01:00