1
0
Fork 0
mirror of https://github.com/AquariaOSE/Aquaria.git synced 2024-12-03 16:35:45 +00:00
Commit graph

17 commits

Author SHA1 Message Date
fgenesis
8472718fb7 Major include refactor; changes to pretty much everything
This untangles some of the gigantic kitchen sink headers
in an attempt to split things into smaller files.
Also don't include gl.h, glext.h, windows.h,
and other such nonsense *everywhere*.

Lots of cleanups on the way too. More dead/unused code removal.

Remove incrFlag(), decrFlag() Lua functions.
2016-07-09 04:18:40 +02:00
Nicolas Braud-Santoni
eb128e65a4 Remove commented-out code 2016-05-05 19:57:50 +02:00
fgenesis
ce7239056b Minimap icon overhaul:
- Allow specifying custom minimap icons for nodes and entities
- Allow overriding minimap textures
- This removes various hacks in MiniMapRender and related
- Allow access to the MiniMapRender object via Lua
  (don't delete it or the game will crash)

Little extra: Added destructors for some entity classes
2016-03-21 03:40:56 +01:00
fgenesis
300f326777 Use std::vector instead of std::list for RenderObject children 2014-07-21 22:21:22 +02:00
fgenesis
209ad526c6 Add canShotHit() interface function
Let entity decide if it wants to collide with shot or not.
2014-04-01 18:16:33 +02:00
fgenesis
a91a22f463 Cleaning out some dead code.
This adds a small compile error, to be fixed in next commit.
2013-09-04 16:07:46 +02:00
fgenesis
c2506d5bb2 Make some ints floats. 2013-07-20 20:17:57 +02:00
fgenesis
7fb9204e97 Minor changes & simplifications to Lua interface. 5 new functions.
This changes all typical vector interpolation functions that get
value, time, loopType, pingPong, ease as args from the Lua state;
use unified functions for all value type occurances.
This fixes the slightly annoying problem that it was not possible to
pass a boolean true to pingPong or ease, because lua_tonumber() would
always return 0 in that case.

Also changed:
- obj_getWorldPosition() now takes optional x,y-vector

New:
- obj_getWorldPositionAndRotation() is a more efficient shortcut,
	as often both position and rotation are retrieved together,
	and the underlying matrix chain operation is rather expensive.
- entity_getEmitter()
- entity_getNumEmitters()
- setSceneColor2()
- getSceneColor2()
2013-07-20 17:44:27 +02:00
fgenesis
3ed40e73d3 Minor refactor & add Lua funcs:
+ avatar_setShieldActive()
+ entity_isFillGrid()
* entity_setBoneLock() code made easier to read and not warn on no lock entity
+ entity_getMaxSpeedLerp()
+ entity_isEntityInside()
2013-04-24 04:51:26 +02:00
fgenesis
32aca3b768 Move hair functions to Entity; add quad_setSegs() & obj_setRealRenderPass() 2013-01-03 00:36:24 +01:00
fgenesis
b242d80c75 Some fixes (...)
- Get colliding hair segment
- drop AnimatedSprite & Interpolator classes
- repair entity_setAutoSkeletalUpdate()
- remove some old code
2012-12-13 18:45:07 +01:00
fgenesis
e94de627eb Really fix variadic calls (including self). Also fix avatar_setPullTarget() failing because entities are userdata now.
This does now allow constructs like this, in an entity script:

  function msg(me, a)
      if a > 1 then
          a = a * entity_msg(me, a - 1)
      end
      return a
  end

So that entity_msg(thing, 5) == 120 is true.
2012-03-14 20:11:14 +01:00
fgenesis
273b608214 Misc fixes and cleanups; fixed variadic Lua calls to self.
Script interface:
- entity_msg() will no longer corrupt the Lua stack if sending messages to itself.
- added more info to non-critical Lua errors ("attempt to call a nil value", etc)
- replaced many lua_tostring() with getString(), which does never return NULL.
  This prevents possible crashes when a non-string parameter is passed to functions
  expecting a string.

Misc:
- Removed classes BoxElement, DFSprite, Datafile, and related references.
  They were essentially unused.
- Removed unused Element class member variables.
- Show more lines in the in-game console.
2012-03-14 00:58:59 +01:00
fgenesis
7ff0caaed8 Script interface improvements & extensions.
- Pointer typechecks are now enabled by default.

- enabled all script warnings for non-FULL or DEMO builds by default

- Added generic obj_* functions that operate on any type of RenderObject.
  These give quite low-level control about the renderer, and are quite
  dangerous too.
  Subsequently, many functions sharing the same code (*_setPosition, for example)
  could be removed, and simply call the generic functions after a type check.

- Added interface function deathNotify(). The original logic of death
  notifiers was never used, so i thought i'd make use of it.
  This is useful in scripts to safely drop dangling pointers.

- removed sendEntityMessage, entity_setCollideWithAvatar, entity_setTouchDamage,
  which were essentially no-ops.

- Replaced all unnecessary luaReturnNum(0) and luaReturnInt(0),
  now it does only push a return value on the stack if the function
  is actually supposed to have a retun value.

- Allow variadic calling of entity_msg(). Now any parameters can be passed
  to the function, and the target entity will receive all of them.
  Any values returned from the entity's msg() callback will be returned
  by entity_msg() to the original caller. This allows nice RPC-like
  entity communication.

- fixed possible crash in debugLog, bone_update, entity_debugText

- added an override function for loadfile() that is case-insensitive like dofile()

- entity_createEntity returns the created entity now

- spawnParticleEffect returns the associated RenderObject

- Added some text rendering functions

- Added beam_setFirer()

- removed the underflow check in avatar_decrLeaches() I added earlier

- added a panic function for Lua.

- added the Lua debug library

- fixed a stupid typo in ScriptObject::isType() that made the type checks a lot less accurate

- misc stuff I forgot
2012-02-05 20:22:54 +01:00
fgenesis
4320b8296b Add a safe pointer model to ScriptInterface, additional bug/crash fixes.
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.
2012-01-03 04:38:28 +01:00
fgenesis
c78d4d7a11 Fixed some script interface functions, error handling & code cleanups
== 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.
2011-09-18 23:12:02 +02:00
fgenesis
3096eaf5e2 initial commit. This is icculus version 5542b94cae02a6333845854bbbd1abe0a259f1a4 2011-08-03 22:05:33 +02:00