This commit introduces pointer checks to various functions;
so that entity_* will no longer crash or produce weird results
if passed a Node pointer, etc.
The checks are disabled by default, but can be enabled in
ScriptInterface.cpp.
Fixed possible crashes in a few more functions due to missing NULL-checks.
There was a "feature" in the single Lua state that it would keep globals
intact until the game was quit. That made any globals from mods "leak"
into the game or other mods. Now it resets the Lua state when a mod
is loaded or closed.
- Vector interpolation. Also removed unused interpolation trigger events.
- GridRender::onRender() (removed Andrew's hack, use fixed map file!)
- make use of glVertex3i() & memchr() in GridRender
- very minor misc things
This fixes a bug where loading a normal saved game and then dying in a mod
(or vice versa) would cause the game to attempt loading the save game
in the wrong context, resulting in a blank error map and many
"tile dummy" error messages.
- Vector interpolation. Also removed unused interpolation trigger events.
- Game::collideCircleWithGrid()
- GridRender::onRender() (removed Andrew's hack, use fixed map file!)
- make use of glVertex3i() & memchr() in GridRender
- Finetuned default distance by aspect ratio
- Added a hack to allow entity_sound() to use freq values around 1000 instead of changing all related scripts
- Changed anglerfish bite pitch, 40% only sounds awkward
Apparently this was half implemented but not fully finished.
Mono samples work fine, for stereo, L/R panning does not work (due to OpenAL's limitation)
Also fixed: entity sounds should not play if a cutscene is currently skipped.
- restored leach.lua 1.1.1 compatibility (entity_*TargetLeaches still works)
- fixed possible script warning when picking up a collectible
- made energy bariers ignore damage
This allows reconstructing the map templates, which were never shipped with the game.
This patch also fixes insane memory leaking when taking screenshots, or dumping screen frames.
Mods with a <Properties hasWorldMap="1"> tag in their XML definition
can now open a native world map like the original game.
Fixed an oversight that the world map visited area was updated
while the editor was open.
Fixed missing field in worldmap.txt saving.
Removed the limitation that world map tiles had to be 256x256 -
all tile sizes work now.
The game does now read _mods/#/data/stringbank.txt from a mod and merges
it with the main stringbank.txt, and uses _mods/#/data/worldmap.txt
as a full replacement.
Load _mods/#/[map|premap]_mapname.lua scripts to properly
initialize the Naija map token.
Improved the builtin worldmap editor a little.
Fixed an oversight where not all parallax layers got their parallaxLock
status cleared in case the map file was missing this attribute, or not all
affected layers were listed there.
The editor does now no longer switch to a layer when hiding it
(Alt+Layer key). It is still possible to edit invisible layers, though.
Sometimes the glow render object was added to an array position before
darkness on the layer, which made the glow never visible and never light
up the screen.
Added the same fix to createQuad() Lua func - nodes which spawned a quad
on the dark layer in their init() function had the same problem.
Mods with a <Properties hasWorldMap="1"> tag in their XML definition
can now open a native world map like the original game.
Fixed an oversight that the world map visited area was updated
while the editor was open.
Fixed missing field in worldmap.txt saving.
Removed the limitation that world map tiles had to be 256x256 -
all tile sizes work now.
The game does now read _mods/#/data/stringbank.txt from a mod and merges
it with the main stringbank.txt, and uses _mods/#/data/worldmap.txt
as a full replacement.
Load _mods/#/[map|premap]_mapname.lua scripts to properly
initialize the Naija map token.
Improved the builtin worldmap editor a little.
== Script interface changes: ==
Removed entity_setClampOnSwitchDir(), which was a no-op.
Added entity_getFlag() function, for fairness, as nodes already have one.
Added node_getLabel() function, which does not return the _full_ node string, but only the first part before parameters.
dofile() supports relative paths now, and it is no longer necessary to use appendUserDataPath() + full path from a mod.
entity_color() does now support all interpolation functions that similar vector-manipulation functions support (loop, ping-pong, ease).
added entity_getVel() function (an entity_setVel() can be emulated with entity_clearVel(), followed by entity_addVel()).
*_getNearestNode() and *_getNearestEntity() allow an optional ignore parameter.
node_getNearestNode() allowed to specify a node to exclude from the search,
the others not -- now the interface is more consistent.
Deprecated entity_[incr/decr]TargetLeaches(entity) - the attached leach amount was never handled
by any entity other than Naija. Replaced them with avatar_[incr/decr]Leaches(), but kept the old
ames for now, too. Should be removed in a while.
== Script interface & related fixes: ==
Added bool loudScriptErrors to control displaying script syntax error and global variable usage warnings.
So far, syntax errors always went do debugLog(), but it is less time consuming when writing scripts
to have them displayed right away.
*_getNearestNode now scan by label, and not full name.
This allows searching for nodes but ignoring its parameters. The original game scripts never search
for nodes that have parameters, so this does not break anything,
but allows modding without an exploding amount of specialized node scripts.
entity_setBoneLock() failed for certain entites with throwLuaErrors=true,
allowing to burst through them (gears, grouper, big mithalas jelly, probably more).
Removed unnecessary int-casts in entity_setHealth(), entity_changeHealth(), and a few others,
which truncated float fractional parts.
Fixed possible crashes in many functions due to missing NULL-pointer checks,
if wrong data were passed to Lua.
Optimized entity_getNearestEntity() a little - do nocasecmp() after checking all other params
UPPERCASE global variables as used in mod include files are now tolerated, even with all warnings on.
This makes sense because it was impossible to include a custom flags definition file
(which _must_ have globals, otherwise the including scripts won't see them) in a mod without beeing buried in spam.
They won't change, or clobber any states, and UPPERCASE sort of implies a constant/#define, imho.
Added better control over warnings about not-existing files. map_*.lua and premap_*.lua files are optional,
and no warning should be given if they do not exist. Missing Entity scripts and mod-init.lua must be
warned about, however.
Fixed a crash in global variable access warning (NULL pushed into std::ostringstream)
Fixed 2 random warnings i found in scrips
== Misc stuff: ==
Related to the changes above, cleaned out unused variables from the Entity class,
and removed the code that had to do with them somehow. Some parts of the removed code
were still in use, although totally unnecessary.
Saves a few bytes of memory per entity, and less code that can cause headache.
Added Shift+Mousewheel as faster alternative to E and R for tile selection
(had to change the undocumented and probably unused Shift+R action to Alt+R).
Allow applying element effects (numpad 0-9) to multiple selected tiles,
and not only one.
A new node does no longer have "NewPath" as default text when created,
which always forces the user to hammer backspace 6 times before own text can be entered.
Mods with a <Properties hasWorldMap="1"> tag in their XML definition
can now open a native world map like the original game.
Fixed an oversight that the world map visited area was
updated while the editor was open; fixed worldmap.txt saving;
removed the limitation that world map tiles had to be 256x256 -
all tile sizes work now.
Improved the builtin worldmap editor a little.
The game does now read _mods/#/data/stringbank.txt from a mod and merges
it with the main stringbank.txt, and uses _mods/#/data/worldmap.txt
as a full replacement.
Load _mods/#/[map|premap]_mapname.lua scripts to properly
initialize the Naija map token.