summaryrefslogtreecommitdiffstats
path: root/src
Commit message (Collapse)AuthorAgeFilesLines
* Added chr_kick() lua bindErik Schilling2012-03-141-2/+16
| | | | | | Another step towards scriptable @commands. Reviewed-by: bjorn.
* Added being_get_mapid lua bindErik Schilling2012-03-141-2/+18
| | | | | | Another step for being able to make @commands scriptable Reviewed-by: bjorn.
* Added get_character_by_name lua bindErik Schilling2012-03-145-48/+43
| | | | | | Step to be able to handle chatcommands by scripts. Reviewed-by: bjorn.
* Fixed problems with map-bound world state variablesThorbjørn Lindeijer2012-03-1310-64/+134
| | | | | | | | | | | | | | | | | | Due to a wrong primary key, which covered only the state name, it was impossible to use the same state name on different maps. This has now been fixed. Another problem was that the map variables were being included in the global variables, because the related database query did not filter on the map_id column properly. While fixing that, the map_id column now allows explicitly marking a state variable as global (with the value 0) or system variables (with the value -1). System variables are currently not accessible from scripts, but that could be changed later. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
* SQLite: Fixed SqLiteDataProvider::processSql handling of multiple rowsThorbjørn Lindeijer2012-03-131-5/+7
| | | | | | | | | | | When a prepared SQL statement would have returned multiple rows, this function would try to set the column header names multiple times which throws the AlreadySetException. Currently it doesn't seem that any prepared statements are meant to return multiple rows. Reviewed-by: Yohann Ferreira
* Fixed initial sending of global world variables to the game serverThorbjørn Lindeijer2012-03-131-1/+2
| | | | | | | The AGMSG_REGISTER_RESPONSE message should be sent _after_ adding the global world state variables to it rather than before. Reviewed-by: Yohann Ferreira
* Added script bind to set walkmask for beingsErik Schilling2012-03-139-28/+63
| | | | | | TODO: Inform client about this change. Reviewed-by: bjorn.
* Removed "mana." from script function documentationThorbjørn Lindeijer2012-03-111-102/+99
| | | | Forgot to do this in the previous commit.
* Register Lua script API functions into the global namespaceThorbjørn Lindeijer2012-03-111-2/+3
| | | | | | | | Scripts mostly execute the Mana script API, and it seems like just unnecessary verbosity to refer to the 'mana' table all the time. This table no longer exists now. Reviewed-by: Erik Schilling
* Removed the create_npc wrapper and the last two NPC callbacksThorbjørn Lindeijer2012-03-1111-72/+156
| | | | | | | | | | | | When creating an NPC, you now provide its optional talk and update functions directly rather than them being stored in a table on the Lua side and then called in response to a global callback. Also fixed an issue with a missing gender parameter to the delayed NPC creation callback used by NPCs defined on the map (found by Erik while reviewing this patch). Reviewed-by: Erik Schilling
* Added callbacks for map/worldvar changesErik Schilling2012-03-116-3/+104
| | | | Reviewed-by: bjorn.
* Moved the managing of NPC script coroutines into C++Thorbjørn Lindeijer2012-03-1015-222/+443
| | | | | | | | | | | | Rather than wrapping NPC functions up in coroutines in the Lua side, they are now managed on the C++ side as "script threads", which are essentially the same thing. The main purpose is that the server can now know whether any of these long running script interactions are still active, which will probably be useful when adding the ability to reload scripts. Reviewed-by: Erik Schilling
* Removed space before ;Erik Schilling2012-03-101-1/+1
| | | | Reviewed-by: PjotrOrial.
* Fixed compileThorbjørn Lindeijer2012-03-071-1/+1
| | | | This was meant to be amended to the previous commit...
* Added a function that returns the current map or raises an errorThorbjørn Lindeijer2012-03-075-136/+80
| | | | | | | | | | | The new function 'checkCurrentMap' will raise an error when no current map has been set, eliminating the need to do custom error handling all over the place. This also fixes several functions that would otherwise have simply crashed when there was no current map. Also cleaned up some "empty string parameter" checks. Reviewed-by: Erik Schilling
* Added @effect commandErik Schilling2012-03-051-0/+48
| | | | | | | | | Usage: @effect <id> @effect <id> <char> @effect <id> <x> <y> Reviewed-by: Bertram.
* Added lua function for getting pvp status of mapErik Schilling2012-03-052-2/+15
| | | | | | mana.map_get_pvp() now returns one of the constants in libmana-constants.lua Reviewed-by: Bertram.
* Added possibility to make a being attack an other beingErik Schilling2012-03-054-35/+61
| | | | | | | | | | | | | This allows the script to let the character perform a scripted attack but the character still gets xp and killed monsters give drops. You can now call: mana.being_damage(target, dmg, dmg_delta, accurancy, type, element, source, skill) While on it I also added checks to the being_damage function. Reviewed-by: bjorn, Bertram.
* Improved Lua API argument checkingThorbjørn Lindeijer2012-03-053-580/+194
| | | | | | | | | | | It's a bit embarrassing the way this has gotten out of hand. The error checking was inconsistent, and in some cases wrong. A host of new helper functions, starting with 'check' rather than 'get', perform error handling on function arguments (they will not return when encountering an error). Reviewed-by: Erik Schilling
* SQLite: Added a timeout for trying to acquire a database lockThorbjørn Lindeijer2012-03-041-0/+4
| | | | | | | | | | | Without a timeout, trying to write to a locked database fails immediately. Now it will only fail when it can't retrieve a write lock within a second. Still, we need to go through all the SQLite code some time, since there is a lot of error handling missing. We also need to make sure that errors are handled correctly on the higher level. Reviewed-by: Yohann Ferreira
* Removed the last direct call to global script functionThorbjørn Lindeijer2012-03-036-39/+30
| | | | | | | | | | | | The ScriptAction of the TriggerArea (which can be created by mana.trigger_create) was still using a named global function for its callback. Now it also uses a reference to a script function. Since it was the last occurrence of a call to a global script function, I've also removed the Script::prepare(std::string) overload. Reviewed-by: Erik Schilling Mantis-issue: 299
* Improved handling of item and monster class parametersThorbjørn Lindeijer2012-03-033-163/+108
| | | | | | | | | | | Item and monster classes could already be identified by either their id or their name. Now the explicit values returned by 'get_item_class' and 'get_monster_class' can also be used as parameter. In addition the above two getters learned to understand all three types of parameter as well, rather than only supporting a name. Reviewed-by: Erik Schilling
* Use callbacks for items, monsters and status effectsThorbjørn Lindeijer2012-03-0313-127/+241
| | | | | | | | | | | | | Previously, global function names were defined in the respective XML definitions of items, monsters and status effects. This was reasonable when they all had the same state, but now they're sharing the single global Lua state. Now the Lua API provides access to the ItemClass, MonsterClass and StatusEffect instances, on which callbacks for both standard and custom events can be explicitly set. Reviewed-by: Erik Schilling
* Added further missing callbacksErik Schilling2012-03-039-20/+222
| | | | Reviewed-by: bjorn.
* Converted functions called by LuaScript to callbacksThorbjørn Lindeijer2012-03-029-55/+119
| | | | | | | | | | This includes the quest reply, post reply, death notification and remove notification. Also, Script::Ref was changed from a typedef to a small class, automating initialization and making the check for validness clearer. Reviewed-by: Erik Schilling
* Use callbacks for handling character death and respawnThorbjørn Lindeijer2012-03-029-27/+114
| | | | | | | | | | | | | | | Rather than relying on the availability of global functions with certain predefined names, the Lua script now calls API functions to set which function should be called on these global events. This mechanism should make it easier to avoid name collisions in the global namespace, which is important now that there is only a single script state. For these global events this was not likely to become a problem, but this solution can also be used for callbacks on specific item or monster types, or even allow setting callbacks on certain instances. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
* Simplified some of the Lua backendThorbjørn Lindeijer2012-03-022-70/+30
| | | | | | | | Mainly introduced a helper function for getting to the Script instance for the current Lua state. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
* Merged all the different Lua states into oneThorbjørn Lindeijer2012-03-0219-267/+259
| | | | | | | | | | | | | | | | | No more Lua state for each status effect, monster, item effect or map. All scripts are loaded into the same state. This should be more efficient overall and make it easier to implement dynamic reloading of the scripts in the future. Now, this introduces the problem of name collisions between different Lua scripts. For now this is solved by using more specific function names, like 'tick_plague' and 'tick_jump' rather than just 'tick'. The plan is however to get rid of these globals, and register these callbacks from the script, so that they can be local functions without the danger of colliding with other scripts. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
* Fixed bug with erasing the last status effectThorbjørn Lindeijer2012-02-281-3/+9
| | | | | | | It's not nice to use ++ on an iterator that may be std::map::end(), in my case this caused it to hang indefinitely. Reviewed-by: Yohann Ferreira
* Removed unnessecary second check for same conditionErik Schilling2012-02-281-65/+62
| | | | Reviewed-by: Bertram.
* Prevent calculating movement of being further if it does not moveErik Schilling2012-02-271-0/+4
| | | | Reviewed-by: bjorn.
* Fixed compilation again + some more code cleanupErik Schilling2012-02-275-20/+21
| | | | | | | | | | I did some cleanup but i had a wrong path set inside qtcreator. So i recompiled old versions and it all worked fine. But when i recompiled from console i got a whole bunch of errors. Sorry for pushing broken commits. Reviewed-by: bjorn.
* Some random code cleanupErik Schilling2012-02-261-33/+25
| | | | | | Moved a code comment about syncmessages to the bugtracker: #473. Reviewed-by: bjorn.
* Renamed some iterators + fixed one TODO (stored guilds in a map)Erik Schilling2012-02-262-46/+23
| | | | Reviewed-by: bjorn.
* Merged the example client and server dataThorbjørn Lindeijer2012-02-251-6/+3
| | | | | | | | | It's easier to just talk about world data and to modify it as a whole. If there is really a need to separate it, a project can still choose to do that (and in whatever suitable way). There is no need to enforce this separation or to do it in our example. Reviewed-by: Erik Schilling
* Added a generic Lua user data cacheThorbjørn Lindeijer2012-02-033-9/+106
| | | | | | | Based on a native Lua table with weak values, so that the user data objects that are created can be garbage collected when no longer referenced. Reviewed-by: Yohann Ferreira
* Clear the gid flags before processing themThorbjørn Lindeijer2012-02-033-13/+22
| | | | | | | Also read the gids as unsigned integers since that's how Tiled writes them to prevent the number going negative when the highest flag is used. Reviewed-by: Yohann Ferreira
* Added a way to specify the min and max attributes values.Yohann Ferreira2012-02-029-81/+129
| | | | | | | | | This can now be done in attributes.xml through the minimum and maximum attribute parameters. I also changed the AttributeInfo struct as requested by bjorn. Reviewed-by: Erik Schilling, Thorbjørn Lindeijer
* Use a full user data object for MapObject referencesThorbjørn Lindeijer2012-01-313-53/+84
| | | | | | | | | | Based on a templated helper class, MapObject references in Lua scripts are now full user data objects. Using the '__index' member of their metatable, a library is associated with it so that member functions can be called directly on the object. Reviewed-by: Yohann Ferreira Reviewed-by: Erik Schilling
* Fixed some lua_newtable/createtable usageThorbjørn Lindeijer2012-01-302-5/+5
| | | | | | | | | | When creating a Lua table, it is possible to specify in advance how many array elements and how many non-array elements this table will contain, to avoid dynamic reallocations while filling the table. This wasn't used optimally by the pushSTLContainer helper methods and some other cases. Reviewed-by: Erik Schilling Reviewed-by: Yohann Ferreira
* Removed unused createRandomPassword functionThorbjørn Lindeijer2012-01-293-99/+0
| | | | Reviewed-by: Erik Schilling
* Fixed use of checkstring method in the script functionsErik Schilling2012-01-251-4/+7
| | | | | | luaL_checkstring might not return so the destructor of string will not be called. Reviewed-by: Bjorn.
* Added announce(text [, sender]) lua functionErik Schilling2012-01-221-4/+18
| | | | | | | The function will cause a global announcement. If no sender ist set "Server" will be used. Reviewed-by: Bjorn.
* Removed logging of chatErik Schilling2012-01-222-15/+0
| | | | Reviewed-by: Bertram
* Made @announce fully functionalErik Schilling2012-01-215-47/+40
| | | | | | | - Added announcements having senders now. - Removed /announcement support. Reviewed-by: Bjorn.
* Added the chr_get_inventory and chr_get_equipment functions.Yohann Ferreira2012-01-181-0/+137
| | | | | | | | | | | Those will make the scripters able to get a full view of the current player's possessions. Use with care. + Fixes following Ablu's review. Resolves: Mana-Mantis #207. Reviewed-by: Ablu
* Fixed the chr_inv_count function to handle equipment.Yohann Ferreira2012-01-183-16/+48
| | | | | | | | | | | | | | | the function can now count in the inventory and/or the player's equipment. I also fixed the script function and added a use case in the example map. + Fixes after Ablu's review. + 2nd fix after Ablu's review: Fix the inventory remove behaviour. Resolves: Mana-Mantis #288 Reviewed-by: Ablu
* Made the lua item_drop script function returns whether it succeeded.Yohann Ferreira2012-01-161-4/+4
| | | | | | Part of Mana-Mantis #339. Reviewed-by: Ablu
* Added several script warnings on errors.Yohann Ferreira2012-01-161-7/+10
| | | | | | As requested by Ablu. Reviewed-by: Ablu.
* Made the game server execute the chr_respawn_accept script evenYohann Ferreira2012-01-104-19/+52
| | | | | | | | | | | | | | | | | | | in case of disconnection. I made the Character::disconnected() function handle that case, permitting also to centralize GameState::remove() calls there. I also made the GameState::enqueueWarp() function test whether the Character pointer is about to be deleted, so that the warp can be handled directly to avoid a crash. Last but not least, I also made the Character::update() function not update the Character specials and hp to avoid discrepancies seen in the client. Resolves: Mana-Mantis #309. Reviewed-by: Ablu.