summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)AuthorFilesLines
2011-04-10Initialize attribute base and cached modified valuesThorbjørn Lindeijer1-0/+2
Attributes that didn't get a value yet are not communicated from account to game server. This could leave some attributes with uninitialized (random) values, like the amount of gold or some uncalculated attack speed bonus. Defaulting the value to 0 seems to be appropriate for all current cases. When another default value should be used, it can be specified in attributes.xml and will be sent from the account server. Reviewed-by: Stefan Dombrowski
2011-04-10Fixed infinite loop in deserializeCharacterDataThorbjørn Lindeijer1-10/+5
Could happen on servers where a character is being communicated that has something equipped. The infinite loop was due to using "while (msg.getUnreadLength())" on a message after having read one byte too much, causing it to miss the 0 bytes unread and count to minus infinity. This is a danger that we should probably also fix generally. The byte that was read too much was equipmentInSlotType, which I think should have been the number of items equipped in a certain slot type. This number is never written by the serializeCharacterData function and also doesn't seem necessary. When multiple items are equipped in a single equipment slot type, there will simply be multiple pairs transmitted for that equipment slot type. Reviewed-by: Freeyorp
2011-04-04Fixing reading of drop rate from monsters.xmlStefan Dombrowski1-2/+2
The xml gives the drop rate as a floating point number. Also added 0.5 for correct rounding. (Without it 0.7% calculates to 69.) Reviewed-by: Jaxad0127
2011-04-03Changed SYNC_BUFFER_SIZE to unsigned to avoid compiler warningThorbjørn Lindeijer1-2/+5
It's being compared to an unsigned integer. Reported-by: Stefan Dombrowski
2011-04-02Split GameHandler::processMessage up into multiple functionsThorbjørn Lindeijer2-394/+481
One huge function that handles all the messages isn't very readable and causes everything to be indented by several levels. Hence we generally split this up. It also exposed a missing 'break;' when handling the PGMSG_USE_SPECIAL message, which would continue into the handling of PGMSG_ACTION_CHANGE. Reviewed-by: Stefan Dombrowski
2011-04-02Some ChatHandler cleanupsThorbjørn Lindeijer4-121/+21
* Removed a lot of pointless documentation that was mainly repeating the function name and otherwise just filling up space. * Synced a few method names to the names of the messages that they were handling. * Removed an unimplemented method (sendPartyMemberInfo) Reviewed-by: Jared Adams
2011-04-02Some cleanups related to syncing from game to account serverThorbjørn Lindeijer4-35/+27
* Remove SYNC_END_OF_BUFFER since the end of a message can already be identified by no more data being available. * Consistently prefix ++ rather than postfix ++ when incrementing mSyncMessages. * Made SYNC_BUFFER_SIZE into constants rather than defines, and moved them into the .cpp file since they're not used anywhere else. * Just use 1 and 0 to indicate online status. No point in writing it like 0x01 and 0x00. * Merged some duplicated documentation for AccountConnection::syncChanges. Reviewed-by: Jared Adams
2011-03-31Fixing account server crash when leaving guildStefan Dombrowski1-1/+3
This resolves http://bugs.manasource.org/view.php?id=323
2011-03-30Fixing selection of a character if lower slots are emptyStefan Dombrowski1-1/+1
This resolves http://bugs.manasource.org/view.php?id=321 Reviewed-by: Jaxad0127, VUT
2011-03-24Rely more on the functionality in XML::DocumentThorbjørn Lindeijer7-79/+22
By default XML::Document will use the ResourceManager to resolve the file name you pass to it. There is no point in disabling that functionality only to resolve it manually. Reviewed-by: Jared Adams
2011-03-24Use a map to quickly find items and monsters by their nameThorbjørn Lindeijer5-59/+90
Introduced a template class NameMap, which provides a nice API for mapping any custom types by their name. This change also makes any duplicate item or monster definitions be complete ignored, rather than being merged into the first definition. Reviewed-by: Philipp Sehmisch Reviewed-by: Yohann Ferreira
2011-03-23Fixed problems with loading XML files containing Windows newlinesThorbjørn Lindeijer5-154/+37
By using xmlParseFile instead of xmlParseMemory, the system-dependent newlines should be handled automatically. The .tmx.gz files should still be supported, but instead of manually decompressing them the xmlParseFile function should take care of that. It also fixes the leaking of XML documents in both the SkillManager as well as the PermissionManager, since they now rely on XML::Document, which cleans up automatically. Reviewed-by: Stefan Dombrowski
2011-03-23Simplify implementation of fileExistsThorbjørn Lindeijer1-26/+8
2011-03-20Renamed some members to adhere to naming standardThorbjørn Lindeijer2-25/+25
2011-03-20Introduced separate functions for item database loadingThorbjørn Lindeijer3-299/+337
This splits the huge ItemManager::reload() into readEquipSlotsFile() and readItemsFile(), the latter of which is further split up into multiple functions for reading the different elements. Just to keep the amount of nesting down and increase the readability. Removes the need for huge eye-catching comment blocks. Reviewed-by: Freeyorp
2011-03-20Introduced ModifierLocation structThorbjørn Lindeijer3-25/+41
Easier to understand than a std::pair<unsigned int, unsigned int>, or functions like getTagFromInfo(unsigned int, unsigned int), which does not make clear what that "info" actually is. Now it's simply getTag(const ModifierLocation &location), documenting itself and also allowing the name to be shorter. Reviewed-by: Freeyorp
2011-03-20Introduced some functions for reading the attributes fileThorbjørn Lindeijer2-148/+159
Keeps the code indentation within reasonable limits and makes the structure easier to follow. Reviewed-by: Freeyorp
2011-03-20Renaming stuff to make the code more readableThorbjørn Lindeijer7-34/+36
SCOPE_TYPES -> ScopeType (plural was confusing) ATTR_BEING -> BeingScope ATTR_CHAR -> CharacterScope ATTR_MOD -> MonsterScope ATTR_MAX -> MaxScope AttributeScopes -> AttributeScope (A single scope seems to include multiple lists of attributes. Seems wrong to me to name this type in plural form.) getAttributeInfoForType -> getAttributeScope (just naming it after what it is actually returning) Reviewed-by: Freeyorp
2011-03-20Moved defines.h and manaserv_protocol.h into 'common'Thorbjørn Lindeijer24-28/+29
Just seems a bit more organized to me.
2011-03-20Some renamings to try to make things more readableThorbjørn Lindeijer4-110/+146
AT_TY -> StackableType TY_ST -> Stackable TY_NST -> NonStackable TY_NSTB -> NonStackableBonus AME_TY -> ModifierEffectType AME_MULT -> Multiplicative AME_ADD -> Additive Got rid of related documentation, which is now stating the obvious. Also renamed many related variables. Reviewed-by: Freeyorp
2011-03-20Use of uint64_t requires including C99 header stdint.hThorbjørn Lindeijer1-0/+2
This is not standard C++... Reviewed-by: Freeyorp
2011-03-20General cleanups and code style fixesThorbjørn Lindeijer9-125/+107
A bunch of variables that were continuously requested from the configuration are now members of the AccountHandler. Reviewed-by: Freeyorp
2011-03-18Improved error handling in chr_shake_screen Lua functionThorbjørn Lindeijer1-22/+10
It's better to use luaL_checkint than manually checking and printing out an error, since using the helper function makes a more informative error message. Also, scripts errors need to be raised before constructing objects, since due to the way Lua does error handling the destructors of the objects will not be called. Also fixed an issue with the 4th parameter, which was first cast to integer and then multiplied by 10000. Now the multiplication happens before the casting to integer. Reviewed-by: Crush
2011-03-18Improved @ban commandPhilipp Sehmisch4-16/+43
When banning a character, the game master now sets a time unit (m, h, d, w or y for minutes, hours, days, weeks or years) after the duration. Ban durations longer than 2^16 minutes are now possible. The banned character is now kicked automatically and the banning character receives a feedback chat message. Reviewed-by: Thorbjorn
2011-03-17Micro-optimizations related to std::stringThorbjørn Lindeijer26-99/+109
* Rely on the fact that a std::string is empty by default * Use std::string::empty() rather than comparing to "" * Construct with std::string() rather than from "" Reviewed-by: Bertram
2011-03-16Path finding: Moved F cost from PathInfo to LocationThorbjørn Lindeijer1-17/+15
The F cost represents the estimate of the total cost from source to destination. It is only relevant to sort the locations to be checked, so there is no point in assigning it to each coordinate of the map. With maps up to 200x200, the memory usage is reduced by 160 kB! :P Reviewed-by: Bertram
2011-03-16Allowed item names instead of IDs in @commandsPhilipp Sehmisch4-41/+84
The @drop and @item commands can now accept an item name instead of an item ID. In addition the amount can be omitted to create a single item.
2011-03-16Allowed monster names in @spawn commandPhilipp Sehmisch4-17/+67
I rewrote the @spawn command to allow two new things: 1. The monster ID can be replaced with the name of the monster. 2. The amount of monsters can be omitted. In that case a single monster is spawned. Reviewed by: Jaxad and Thorbjorn
2011-03-15Some code style cleanups in AutoAttack classThorbjørn Lindeijer3-31/+77
2011-03-15Moved some file-global variables into the AccountHandlerThorbjørn Lindeijer1-42/+40
Nicer as members where there is clear ownership, initialization and scope. Reviewed-by: Freeyorp
2011-03-15Introduced an AttributeValue class for convenience and readabilityThorbjørn Lindeijer3-29/+43
Easier to understand than a std::pair with its 'first' and 'second' members, and it also provides an implicit constructor so that AttributeValue is implicitly constructed from a double. Reviewed-by: Freeyorp
2011-03-15Eliminated one version of Being::performAttackThorbjørn Lindeijer3-14/+12
There was a version taking an attack range, but the range was always the same as the one specified in the Damage class.
2011-03-14Made the "No game server for map" error message report the map IDPhilipp Sehmisch1-1/+1
(trivial patch)
2011-03-14Script binding for the new screen shake effect.Philipp Sehmisch2-0/+46
The new lua function mana.chr_shake_screen can cause a screen shake for a single client with variable x-intensity, y-intensity, decay and duration. I also added an example script which causes tremors for nearby characters with intensity and direction relative to a specific point. The function is not referenced on the example map because it is quite distracting.
2011-03-13For streaming things to cout better implement stream operatorThorbjørn Lindeijer1-9/+14
More convenient since it doesn't require calling any methods, and a bit faster. Also added stream operator for Rectangle.
2011-03-13Use an enum rather than a bunch of #defines for the attributesThorbjørn Lindeijer1-31/+33
Nicer style.
2011-03-12Added a simple function to easily cout point coordinates.Yohann Ferreira1-1/+10
Reviewed-by: Jaxad0127.
2011-03-12Fixed monster flawed movements and client net messages flooding.Yohann Ferreira1-2/+2
The monsters weren't respecting the end of the stroll time before resetting their destination, which made them never cease changing it and flooded the clients with movement messages. Resolves: Mana-Mantis #315. Reviewed-by: Jaxad0127.
2011-03-12Allow values to be set to empty in the configurationThorbjørn Lindeijer1-10/+10
No reason why these should be ignored and then replaced by their defaults, generally. Reviewed-by: Jared Adams
2011-03-12Removed a bunch of silly documentationThorbjørn Lindeijer32-203/+14
A C++ developer should be able to recognize a constructor and a destructor by just looking at it, so let's stop writing down the obvious. :)
2011-03-11Moved freeing of map position to Actor destructorThorbjørn Lindeijer6-30/+22
It was done in both the Character and the Monster destructors, but I don't see how any Actor should be excluded from this. Now it also happens for NPC, Effect and Item, though only NPC has a relevant walkmask. Also fixed a small issue introduced in 97e0a9eb170499 and added an assert to freeTile. We should be able to assert that a tile can only be freed if it was blocked. Reviewed-by: Stefan Dombrowski
2011-03-11Split path finding out of the Map classThorbjørn Lindeijer7-176/+176
Extracted the path finding algorithm out of the Map class and introduced a new class called PathInfo that has the path finding information that used to be part of MetaTile. This allows a single vector of path information to be shared between all maps running on the server, significantly reducing the memory overhead per map (for 200x200 maps, the memory reduction is about 1 MB per map). Part of this change is some cleanup, like moving the 'occupation' counts into MetaTile, inlining some methods for performance reasons, and using STL to simplify memory management. Mantis-issue: 106 Reviewed-by: Bertram
2011-03-11Fixed Actor::setPosition to update the blockmask correctlyThorbjørn Lindeijer1-8/+6
It was freeing the new tile rather than the previous tile. Reviewed-by: Stefan Dombrowski
2011-03-11Avoid sqrt and double in circle-to-circle collision detectionThorbjørn Lindeijer1-4/+6
We can just stick with integers by trading a sqrt for a multiplication. Reviewed-by: Bertram
2011-03-10Removed two superfluous semicolonsThorbjørn Lindeijer2-2/+2
2011-03-10Server-Wrap the open and closed list members in path finding.Yohann Ferreira2-76/+43
This prevents some weird things happening especially on crowded maps. I also removed the unused findSimplePath() function. Reviewed-by: Thorbjorn.
2011-03-09Prevented a potential crash in storage::getAllWorldStateVars()Yohann Ferreira1-2/+10
Minor other fixes. Trivial.
2011-03-09Renamed GameState::insertSafe() to inserOrDelete.Yohann Ferreira5-8/+8
This reflects much more what the function does IMHO. Trivial.
2011-03-09Made the monster creation delayed, to avoid crashing.Yohann Ferreira1-5/+1
Creation of monsters shouldn't be done during game state update. So we delay their insertion after the update to avoid a crash in debug builds and weird stuff happening in release builds. Reviewed-by: Thorbjorn.
2011-03-06Small fixes coming from my comment on issue #77.Yohann Ferreira5-19/+22
Trivial.