Commit Graph

141 Commits

Author SHA1 Message Date
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
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 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 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 d86f03e2e0 - reverted most of the last commit after realizing that trying to manage constructing/destructing per variable is not going to work because it'd require some extensive exception management in the compiled VM code.
- instead add a list of SpecialInits to VMScriptFunction so this can be done transparently when setting up and popping the stack frame. The only drawback is that this requires permanent allocation of stack objects for the entire lifetime of a function but this is a relatively small tradeoff for significantly reduced maintenance work throughout.
- removed most #include "vm.h", because nearly all files already pull this in through dobject.h.
2016-11-17 13:10:19 +01:00
Christoph Oelckers 384f4fe7ce - added a 'DefaultStateUsage' property so that this setting can be properly set up for the classes that can inject states into other actors. 2016-11-14 18:31:12 +01:00
Christoph Oelckers 199e2e2f9c - fixed CheckRange return value.
- removed the error message for multiple state blocks in DECORATE.
- added some constants for state types.
2016-11-14 17:50:09 +01:00
Christoph Oelckers ac86a535e7 - fixed: State labels were resolved in the calling function's context instead of the called function one's.
This could cause problems with functions that take states as parameters but use them to set them internally instead of passing them through the A_Jump interface back to the caller, like A_Chase or A_LookEx.
This required some quite significant refactoring because the entire state resolution logic had been baked into the compiler which turned out to be a major maintenance problem.
Fixed this by adding a new builtin type 'statelabel'. This is an opaque identifier representing a state, with the actual data either directly encoded into the number for single label state or an index into a state information table.
The state resolution is now the task of the called function as it should always have remained. Note, that this required giving back the 'action' qualifier to most state jumping functions.

- refactored most A_Jump checkers to a two stage setup with a pure checker that returns a boolean and a scripted A_Jump wrapper, for some simpler checks the checker function was entirely omitted and calculated inline in the A_Jump function. It is strongly recommended to use the boolean checkers unless using an inline function invocation in a state as they lead to vastly clearer code and offer more flexibility.

- let Min() and Max() use the OP_MIN and OP_MAX opcodes. Although these were present, these function were implemented using some grossly inefficient branching tests.
- the DECORATE 'state' cast kludge will now actually call ResolveState because a state label is not a state and needs conversion.
2016-11-14 14:12:27 +01:00
Christoph Oelckers 6529931281 fixed and completed the special field init code. Strings can now be used as class members, and so can structs which contain strings.
- made 'DamageMultiply' an actor property and moved the initialization of ConversationRoot to the property handler for the compiler to get this stuff out of the type classes.
- consolidate default initialization into one function which performs all the required setup. The original implementation did this when adding the fields but that cannot work because at that time no defaults have been created yet.
- fixed: When deriving a class the child class's defaults also must initialize the copied parent fields with special initialization. This part was completely missing.
- removed DECORATE code for parsing native classes because it's no longer needed.
2016-11-11 14:40:32 +01:00
Christoph Oelckers f8ccda2dc8 - scriptified A_Mushroom to test something a bit more complex.
- fixed: FxMinusSign trashed local variables that were used with negation.
- fixed: FxConditional only handled ints and floats, but not pointers and strings.
- fixed: A 'no states in non-actors' error was triggered, even for classes without any states.
2016-10-30 14:00:11 +01:00
Christoph Oelckers 948ef62fcd - use the function defaults from the script instead of explicitly setting them again in the code. This is a needless cause of potential errors and since the values are readily available now it's better to use them in the functions.
- fixed: ZCCCompiler did not process array access nodes.
- fixed: Function argument names were not placed in the destination list by the compiler.
- scriptified several trivial functions from p_actionfunctions.cpp.
2016-10-27 15:53:53 +02:00
Christoph Oelckers 371712c53a - turned everything I could into non-action functions.
- fixed emission of the self pointer in FxVMFunctionCall. I did not realize that the self expression only sets up a register for the value, not pushing it onto the stack.
2016-10-22 17:49:08 +02:00
Christoph Oelckers 59ed26c0b6 - resorted some of thingdef.cpp's contents into more appropriate files.
- split FinishActor into several functions. While DECORATE can, ZSCRIPT cannot do all this in one go.
- split the state finalization into several class-specific virtual functions.
2016-10-12 20:42:41 +02:00
Christoph Oelckers b1a83bfd26 - started with cleanup and separation of DECORATE code.
* everything related to scripting is now placed in a subdirectory 'scripting', which itself is separated into DECORATE, ZSCRIPT, the VM and code generation.
 * a few items have been moved to different headers so that the DECORATE parser definitions can mostly be kept local. The only exception at the moment is the flags interface on which 3 source files depend.
2016-10-12 19:22:33 +02:00
Christoph Oelckers 970c168b13 - re-added serialization of treanslations.
- removed more dead code.
2016-09-20 19:45:32 +02:00
Christoph Oelckers 42e38f6cc1 - more cleanup to reduce references to FArchive. 2016-09-20 10:59:48 +02:00
Christoph Oelckers cfaa3e3fa9 - changed action function interface so that callers can be identified directly, instead of guessing it from looking at the parameters.
With arbitrary PSP layers the old method was no longer safe because the layer ID was not available in the action function.
2016-06-16 16:16:27 +02:00
Randy Heit 60966f472f Revert "Revert "Remove "action" from Actor functions that don't actually need it""
- This reverts commit 06216d733e.
- I don't know what I was thinking. Since stateowner is always available
  to the wrapper function, and this code is only generated for the wrapper
  function, it's a nonissue. The state is already located before calling
  any function that uses it.
2016-04-19 21:09:15 -05:00
Randy Heit 06216d733e Revert "Remove "action" from Actor functions that don't actually need it"
- This reverts commit 39df62b20e.
- Anything that needs to lookup a state also needs stateowner. See
  FxMultiNameState::Emit(). I will need to be more selective when
  de-actionifying functions.
2016-04-19 20:56:43 -05:00
Randy Heit 39df62b20e Remove "action" from Actor functions that don't actually need it
- An actor function really only needs to be an action function if:
  1. It can be called with no parameters specified, either because it takes
     none or because all its parameters are optional. This lets SetState()
     call it directly without creating a wrapper function for it.
  2. It wants access to the callingstate or stateowner parameters. Most
     functions don't care about them, so passing them is superfluous.
2016-04-19 20:28:49 -05:00
Christoph Oelckers 3f0ed5d252 - added a distancecheck property to AActor that allows a given CVAR to be used as maximum display distance for actors of this type.
This is for WolfenDoom: BOA, which has some scripted sprite distance checks that very negatively affected performance.
2016-04-12 19:44:12 +02:00
Christoph Oelckers 6c9e5b03c8 - floatified meleerange, pushfactor and radiusdamagefactor, 2016-03-24 21:31:04 +01:00
Christoph Oelckers c83ad9df6c - removed special treatment for not using stdint.h with MSVC. Current compiler versions have this file.
- removed use of finesine for creating the player backdrop for the menu display. This mostly uses the code from the old 2.0 floating point version but fixes some of the constants in there which were not correct.
2016-03-24 11:30:11 +01:00
Christoph Oelckers af427b80bd - did some cleanup and consolidation on damage factor code while converting it all to floating point.
- made armor properties floating point.
2016-03-22 16:35:41 +01:00
Christoph Oelckers cff8e51811 - converted AActor::height to double. 2016-03-20 20:55:06 +01:00
Christoph Oelckers 8362c6a856 - conversion of floorz to double. 2016-03-20 19:52:35 +01:00
Christoph Oelckers 51b05d331d - replaced AActor::vel and player_t::Vel with a floating point version.
- Converted P_MovePlayer and all associated variables to floating point because this wasn't working well with a mixture between float and fixed.

Like the angle commit this has just been patched up to compile, the bulk of work is yet to be done.
2016-03-20 00:54:18 +01:00
Randy Heit 55142078d8 Normalize line endings 2016-03-01 09:47:10 -06:00
Randy Heit b2ccd0bd28 Use action function return value to make state jumps happen
- The A_Jump family of action functions now return the state to jump
  to (NULL if no jump is to be taken) instead of jumping directly.
  It is the caller's responsibility to handle the jump. This will
  make it possible to use their results in if statements and
  do something other than jump.
- DECORATE return statements can now return the result of a function
  (but not any random expression--it must be a function call). To
  make a jump happen from inside a multi-action block, you must
  return the value of an A_Jump function. e.g.:
    { return A_Jump(128, "SomeState"); }
- The VMFunction class now contains its prototype instead of storing
  it at a higher level in PFunction. This is so that
  FState::CallAction can easily tell if a function returns a state.
- Removed the FxTailable class because with explicit return
  statements, it's not useful anymore.
2016-02-18 20:39:40 -06:00
Christoph Oelckers d1b2ef5368 - some refactoring of olddecorations.cpp to move some repeated code into a subfunction. 2016-02-10 14:38:08 +01:00
Christoph Oelckers 3358181f18 - cleaned up the class data organization:
* moved RestrictedToPlayerClass and ForbiddenToPlayerClass arrays to AInventory.
 * moved all copy-from-parent code into DeriveData functions.
2016-02-10 00:46:51 +01:00
Christoph Oelckers 6ce0c9f78e - split up PClass::Derive and its child functions because part of them is also needed when initializing an inherited native class with the properties of its parent - but calling the base version in PClass is not possible.
- moved a few AActor properties out of the EXE so that I could easily test if it works.
2016-02-10 00:17:00 +01:00
Christoph Oelckers b484cbf18a - fixed: It is not guaranteed that the class object that is created by FindClassTentative actually matches the real object that is required later, so it needs to be replaced wherever it could be referenced once the real object is created.
- removed some unneeded code from earlier attempts to fix the class type resolving issue.
2016-02-09 23:08:51 +01:00
Christoph Oelckers e88901f4b7 - added the EE-Extradata parser I wrote for GZDoom so I can use the Vaporware demo map for testing portal stuff. 2016-02-05 23:51:28 +01:00
Christoph Oelckers bf747075e8 Merge branch 'master' into scripting
Conflicts:
	src/actor.h
	src/g_hexen/a_clericstaff.cpp
	src/p_enemy.cpp
	src/p_interaction.cpp
	src/p_local.h
	src/p_mobj.cpp
	src/thingdef/thingdef_codeptr.cpp
2016-01-17 20:57:55 +01:00
Christoph Oelckers bd95c5eadf - fixed: the ambient sound things need both the args from the DoomEdNum mapping and the actual map. 2016-01-04 11:52:07 +01:00
Christoph Oelckers 8447990889 Merge commit '2719ce86dc07c9f7b1ad6d61a9a49c974896abf2' into scripting
Conflicts:
	src/info.h
	src/thingdef/thingdef_codeptr.cpp

(until right before the main work for multiple tags.)
2015-04-28 13:32:50 +02:00
Christoph Oelckers f7834061df Merge commit 'b6a4511dd1e74440fad99bc673c1f2b3680dba48' into scripting
Conflicts:
	src/dobjtype.cpp
	src/p_conversation.cpp
	src/p_local.h
	src/p_things.cpp
	src/thingdef/thingdef_properties.cpp

(This is just the conversationID to MAPINFO stuff to keep the conflicts as small as possible)
2015-04-28 13:08:18 +02:00
Christoph Oelckers ddced06be2 Merge commit '6e45c565a0bc8d05279b0b2458a3fb718ae0924c' into scripting
Conflicts:
	src/p_mobj.cpp

(This stops right before moving the conversation IDs into MAPINFO because that feature is quite conflict-heavy and will have to merged by itself.)
2015-04-28 12:59:20 +02:00
Christoph Oelckers 065c0a79cd Merge commit '4f7ec3ad891d556c0d3f680e209a120ed38e9cdb' into scripting
Conflicts:
	src/d_main.cpp
	src/info.cpp
	src/info.h
	src/p_acs.cpp
	src/p_interaction.cpp
	src/p_mobj.cpp
	src/thingdef/thingdef_codeptr.cpp
	src/thingdef/thingdef_properties.cpp

(scripting branch update part 5)
2015-04-28 12:48:33 +02:00
Christoph Oelckers d6e3fc0567 Merge commit 'fb9231a38db2025eb77bfd246f36d985cbbccd2e' into scripting
Conflicts:
	src/info.cpp
	src/thingdef/thingdef_expression.cpp
	wadsrc/static/actors/constants.txt

(Scripting branch update part 2)
2015-04-28 09:57:01 +02:00
Christoph Oelckers c5a4221b58 - fixed handling of args for non-actor mapthings again. As it turns out there was insufficient information in the data to properly decide this case so a new flag was added to make it all more reliable. 2015-04-07 16:27:57 +02:00
Christoph Oelckers b6a4511dd1 - move conversation ID definition to MAPINFO as well. Uses the newly added filter feature to handle the teaser differences. 2015-04-05 00:31:15 +02:00
Christoph Oelckers 51591d10b0 - handle slope things through new definition tables as well. Since these get processed outside P_SpawnMapThing it required some restructuring so that the actual spawn data is present when slope things get processed.
- removed FMapThing::Serialize because it isn't used anywhere - it was rather broken anyway.
2015-04-04 10:25:01 +02:00
Christoph Oelckers 9e5bf38123 - handle all special mapthing items (player starts, polyobj spots) via the new MAPINFO method instead of hard coding them in the spawn function.
(Note: The buildmap loading code should be adjusted to the new functionality as well eventually.)
2015-04-03 21:17:10 +02:00
Christoph Oelckers 15dbbc9137 - set editor numbers through MAPINFO. The DECORATE way still works ans will override any definition made in MAPINFO.
- use a standard TMap for finding editor numbers
2015-04-03 16:51:45 +02:00
Christoph Oelckers 3a504da675 - forgot to save this before committing. 2015-02-07 19:04:43 +01:00
Christoph Oelckers 7789975b6c - reverted a few of Zzombo's changes. 2015-02-07 17:02:46 +01:00
ZzZombo 322742d4b1 - Fixed various instances of unused variables, accessing arrays out of bounds, initialization of non-primitive members in constructor's body, dead code, passing parameters by value instead of reference, usage of uninitialized variables, as reported by cppcheck. 2015-02-07 23:35:23 +08:00
Randy Heit 2d87eb0ba2 Merge branch 'master' into gonesolong
Conflicts:
	src/CMakeLists.txt
	src/actor.h
	src/g_heretic/a_hereticmisc.cpp
	src/g_heretic/a_hereticweaps.cpp
	src/g_heretic/a_ironlich.cpp
	src/info.h
	src/namedef.h
	src/p_buildmap.cpp
	src/p_enemy.cpp
	src/p_map.cpp
	src/p_mobj.cpp
	src/thingdef/thingdef_codeptr.cpp
	zdoom.vcproj
2014-12-20 19:13:14 -06:00