Commit Graph

126 Commits

Author SHA1 Message Date
Vincent_Michael
20004050bc Update copyright note for 2014.
Happy new year.
2014-01-01 00:07:53 +01:00
jackpoz
1c0903e286 Core/Misc: Fix some static analysis issues
Fix some static analysis issues about uninitialized values. Most of them are false positives, always initialized before being accessed, while some of them are real issues spotted by valgrind too.
2013-12-14 18:41:26 +01:00
joschiwald
a40e814240 Core/SmartScripts: speedup loading/validating sai scripts from db
Before:
>> Loaded 6953 SmartAI scripts in 3543 ms

After:
>> Loaded SmartAIMgr Helpers in 4 ms
>> Loaded 6953 SmartAI scripts in 95 ms
2013-12-11 18:53:05 +01:00
Malcrom
b407e72339 Core/SmartScript: Allow flag to be added to spell to determine combat movement.
Greatly simplifies SAI combat scripting.
2013-12-03 20:53:33 -03:30
Spp
65cd07a288 Core: Improve error messages for linked_respawn table (and minor cosmetic changes here and there) 2013-11-11 11:03:32 +01:00
Spp
94e2b9332a Core/Logging: Remove LOG_FILTER_XXX defines with it's value (remember logger names are case-sensitive) 2013-11-08 10:50:51 +01:00
Ascathor
2607738990 Core/Code: Unify codestyle for brackets: {} to { }.
Also added missing copyright to some files.
2013-10-27 23:46:02 +01:00
Discover-
0cc32e28e3 Core/SAI: Rename SMART_EVENT_TARGET_CASTING to SMART_EVENT_VICTIM_CASTING as that's what it actually does. It was often confused to use the target_type field instead of the victim. 2013-10-22 15:59:32 +02:00
Shauren
ce55647c41 Core/Transports
* Rewritten path generation, now uses splines - timers are a lot more accurate now
* Implemented stopping transports
* Implemented spawning transports in instances
* Implemented spawning gameobjects as transport passengers
* Transport passengers are now stored in creature/gameobject table using gameobject_template.data6 from transport's template as map id
2013-10-16 18:37:29 +02:00
Discover-
80ce30ac7d Core/SAI: Add 'playerOnly' parameters to SMART_TARGET_CLOSEST_ENEMY and SMART_TARGET_CLOSEST_FRIENDLY. Wiki is updated accordingly. 2013-09-30 10:11:02 +02:00
Discover-
a5c248b60f Core/SAI: Get rid of unused parameter 'storageId' (third) in SMART_ACTION_SUMMON_CREATURE. This means the 4th parameter (actionInvoker 0/1) must move back one parameter. On a clean TDB there is not a single case of this parameter being used.
Updated wiki accordingly.
2013-09-25 11:46:51 +02:00
jackpoz
ec3832c2c1 Core/AI: Fix uninitialized values and array overflows in SAI
Proper initialize POD struct members to 0 in SMART_ACTION_CREATE_TIMED_EVENT action type.
Fix array overflows and access uninitialized values in SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST, SMART_ACTION_RANDOM_PHASE and SMART_ACTION_RANDOM_EMOTE .

Valgrind log for SMART_ACTION_RANDOM_PHASE case:
 Conditional jump or move depends on uninitialised value(s)
   at : SmartScript::UpdateTimer(SmartScriptHolder&, unsigned int) (SmartScript.cpp:3086)
   by : SmartScript::OnUpdate(unsigned int) (SmartScript.cpp:3176)
   by : SmartAI::UpdateAI(unsigned int) (SmartAI.cpp:335)
   by : Creature::Update(unsigned int) (Creature.cpp:542)
   by : TempSummon::Update(unsigned int) (TemporarySummon.cpp:47)

 Uninitialised value was created by a stack allocation
   at : SmartScript::ProcessAction(SmartScriptHolder&, Unit*, unsigned int, unsigned int, bool, SpellInfo const*, GameObject*) (SmartScript.cpp:143)
2013-09-24 23:33:28 +02:00
Nay
582686090d Merge pull request #10685 from Discover-/SmartAI-Target-Casting
Core/SmartAI: Add a spellid to SMART_EVENT_TARGET_CASTING. If left on 0,...
2013-09-01 10:03:45 -07:00
Discover-
016dac995e Core/SmartAI: Add a spellid to SMART_EVENT_TARGET_CASTING. If left on 0, it checks for all spells (like it did without these changes) 2013-09-01 10:49:29 +02:00
Nay
7776016106 Core/Quests: Remove CastedCreatureOrGO method
- Remove EAI's ACTION_T_CAST_EVENT and ACTION_T_CAST_EVENT_ALL
- Remove SAI's SMART_ACTION_CALL_CASTEDCREATUREORGO
- Split QUEST_TRINITY_FLAGS_KILL_OR_CAST into QUEST_TRINITY_FLAGS_KILL and QUEST_TRINITY_FLAGS_CAST
- Assign QUEST_TRINITY_FLAGS_CAST to all the quests that were using RequiredSpellCastX
- (unrelated) Fix a warning in Player.cpp
- Replace CastedCreatureOrGO usage in scripts by KilledMonsterCredit

TODO: Convert the two EAI scripts commented out in the .sql to proper SAI

Closes #10667
2013-08-30 19:32:08 +01:00
xjose93
c3afc00571 Implement SMART_ACTION_GAME_EVENT_STOP (111) and SMART_ACTION_GAME_EVENT_START (112). 2013-08-30 01:23:01 +02:00
Discover-
a0ff0233c5 Core/SmartAI: Implement SMART_TARGET_CLOSEST_FRIENDLY.
Parameter is distance to search for.

Closes #10521
2013-08-15 01:22:22 +01:00
Discover-
8c961687a0 Core/SmartAI: Implement SMART_EVENT_FRIENDLY_HEALTH_PCT.
On current clean TDB, there are a total of 106 creatures using
   SMART_EVENT_FRIENDLY_HEALTH (non-PCT) which has a flat first parameter, but
   only 8 of these use the event correctly (and therefore only 8 of them
   actually work).

Closes #10520
2013-08-15 01:18:10 +01:00
Nay
54d2b73f3c Merge pull request #10513 from Discover-/SmartAI-Casted-CreatureOrGo
Core/SmartAI: Drop support for SMART_ACTION_SEND_CASTCREATUREORGO. It is...
2013-08-11 06:26:52 -07:00
Discover-
80bd5b363a Core/SmartAI: Drop support for SMART_ACTION_SEND_CASTCREATUREORGO. It is unused in the current newest TDB, it never even worked like it should and the exact same purpose of this function is already fulfilled by SMART_ACTION_CALL_CASTEDCREATUREORGO (the correct way). 2013-08-11 02:58:53 +02:00
Discover-
75ca3573c8 Core/SmartAI: Implement SMART_ACTION_SET_POWER, SMART_ACTION_ADD_POWER and SMART_ACTION_REMOVE_POWER (param1 = powertype, param2 = newPower). Required for upcoming EAI to SAI conversion (for ACTION_T_SET_UNIT_FIELD) (only SMART_ACTION_SET_POWER is required for the conversion but might as well do it right when on it). 2013-08-10 14:13:17 +02:00
Nay
eba8c2d345 Merge pull request #10464 from Discover-/SmartAI-Set-Active
Core/SmartAI: Allow SMART_ACTION_SET_ACTIVE to take a parameter for on/o...
2013-08-09 08:44:56 -07:00
Nay
edf77a4cf6 Merge pull request #10493 from Discover-/SmartAI-Action-Sound-Update
Core/SmartAI: Rename SMART_ACTION_SOUND's parameters and get rid of an e...
2013-08-09 08:38:09 -07:00
Discover-
bd2120593d Core/SmartAI: Rename SMART_ACTION_SOUND's parameters and get rid of an error that shouldn't be there. The method it calls doesn't take CreatureTextRange (enum) in consideration, but a boolean called onlySelf. 2013-08-09 01:05:56 +02:00
Discover-
9d4c2c5b1e Core/SmartAI: Implement SMART_TARGET_CLOSEST_ENEMY (25)
Required for upcoming EAI to SAI conversion.

Closes #10482
2013-08-07 19:59:06 +01:00
Discover-
d87b0fff2f Core/SmartAI: Allow SMART_ACTION_SET_ACTIVE to take a parameter for on/off (true/false). Required for upcoming EAI to SAI conversion (https://github.com/Discover-/EventAI-to-SmartAI) 2013-08-07 02:41:58 +02:00
Malcrom
b7dd7f0442 Core/SmartAI: Add ability to modify UNIT_FIELD_FLAGS_2 to SAI actions. 2013-05-26 13:22:21 -02:30
Spp
d1677b2db0 Core/Logging: Performance-related tweaks to logging system
All sLog->out* functions (except outCommand atm) are replaced with TC_LOG_* macros.
    Memleak fix
2013-05-13 15:07:36 +02:00
Gacko
44553d3fd4 Fix some engrish 2013-03-15 16:50:40 +01:00
WyldePointer
47f7687bab Core: Remove unnecessary commas
Last element of enumerator does not need comma after it's value.

Closes #9367
2013-03-09 15:20:57 +00:00
Vincent_Michael
83c98d6dff Core/SmartAI: Implement SMART_ACTION_SUMMON_CREATURE_GROUP (107) 2013-03-09 02:03:37 +01:00
Nefarion
49fd11ab5a First step of comment style refactoring to doxygen-style. 2013-03-08 21:55:37 +01:00
Nay
2d861b71ce Core/SAI: Add actions to set/add/remove (104/105/106) gameobject flags 2013-02-16 18:42:26 +00:00
Vincent_Michael
9d7d68395c Core/SmartAI: Implement SMART_ACTION_SET_ROOT (103) 2013-02-02 18:18:27 +01:00
Nay
8274e42e3d Core/SAI: Add 2nd parameter to SMART_ACTION_CALL_FOR_HELP to say "%s calls for help!" if enabled
Similar to SMART_ACTION_FLEE_FOR_ASSIST "%s attempts to run away in fear!"
2013-01-10 15:09:12 +00:00
Shauren
59e4f6eb05 Core/SmartScripts: Fixed SAI targets 10 & 14 (SMART_TARGET_CREATURE_GUID, SMART_TARGET_GAMEOBJECT_GUID)
Note: If you used these targets to perform actions across maps, it will not work anymore, this functionality is deprecated as it was not safe.
2013-01-03 19:22:12 +01:00
Vincent_Michael
cc65aba789 Update copyright note for 2013.
Happy new year.
2013-01-01 00:41:01 +01:00
Kandera
2e5e8331f3 Core/SmartAI: add SMART_ACTION_SET_HEALTH_REGEN (102). 2012-09-17 14:11:57 -04:00
Spp
358c6a26d6 Core: Warning fixes (Also some -pedantic under game folder) 2012-09-10 13:04:31 +02:00
Santiago
e3b9b15779 Core/SAI: Implement SMART_ACTION_SET_HOME_POS (101)
No parameters; allowed targets: self and position

Closes #7689
2012-09-08 00:55:47 +01:00
Nay
e3d9768a50 Core: Fix many "errors"/warnings and coding style (3)
Game

Errors were found using Cppcheck, open-source static analysis tool
2012-08-30 22:44:33 +01:00
Spp
55ce180f28 Core/Logging: Add Asyncronous logging with Loggers ("What to log") and Appenders ("Where to log") system. Will allow to select to full log some parts of core while others are not even logged.
- Logging System is asyncronous to improve performance.
- Each msg and Logger has a Log Type and Log Level assigned. Each msg is assigned the Logger of same Log Type or "root" Logger is selected if there is no Logger configured for the given Log Type
- Loggers have a list of Appenders to send the msg to. The Msg in the Logger is not sent to Appenders if the msg LogLevel is lower than Logger LogLevel.
- There are three (at the moment) types of Appenders: Console, File or DB (this is WIP, not working ATM). Msg is not written to the resource if msg LogLevel is lower than Appender LogLevel.
- Appender and Console Log levels can be changed while server is active with command '.set loglevel (a/l) name level'

Explanation of use with Sample config:

Appender.Console.Type=1       (1 = Console)
Appender.Console.Level=2      (2 = Debug)

Appender.Server.Type=2        (2 = File)
Appender.Server.Level=3       (3 = Info)
Appender.Server.File=Server.log

Appender.SQL.Type=2           (2 = File)
Appender.SQL.Level=1          (1 = Trace)
Appender.SQL.File=sql.log

Appenders=Console Server      (NOTE: SQL has not been included here... that will make core ignore the config for "SQL" as it's not in this list)

Logger.root.Type=0            (0 = Default - if it's not created by config, server will create it with LogLevel = DISABLED)
Logger.root.Level=5           (5 = Error)
Logger.root.Appenders=Console

Logger.SQL.Type=26            (26 = SQL)
Logger.SQL.Level=3            (2 = Debug)
Logger.SQL.Appenders=Console Server SQL

Logger.SomeRandomName.Type=24 (24 = Guild)
Logger.SomeRandomName.Level=5 (5 = Error)
Loggers=root SQL SomeRandomName

* At loading Appender SQL will be ignored, as it's not present on "Appenders"

* sLog->outDebug(LOG_FILTER_GUILD, "Some log msg related to Guilds")
  - Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomName is found but it's LogLevel = 5 and Msg LogLevel=2... Msg is not logged

* sLog->outError(LOG_FILTER_GUILD, "Some error log msg related to Guilds")
  - Msg is sent to Logger of Type LOG_FILTER_GUILD (24). Logger with name SomeRandomeName is found with proper LogLevel but Logger does not have any Appenders assigned to that logger... Msg is not logged

* sLog->outDebug(LOG_FILTER_SQL, "Some msg related to SQLs")
  - Msg is sent to Logger SQL (matches type), as it matches LogLevel the msg is sent to Appenders Console, Server and SQL
    - Appender Console has lower Log Level: Msg is logged to Console
    - Appender Server has higher Log Level: Msg is not logged to file
    - Appender SQL has lower Log Level: Msg is logged to file sql.log

* sLog->outDebug(LOG_FILTER_BATTLEGROUND, "Some msg related to Battelgrounds")
  - Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). As Logger has higher LogLevel msg is not sent to any appender

* sLog->outError(LOG_FILTER_BATTLEGROUND, "Some error msg related to Battelgrounds")
  - Msg is sent to Logger root (Type 0) as no Logger was found with Type LOG_FILTER_BATTLEGROUND (13). Msg has lower LogLevel and is sent to Appender Console
    - Appender Console has lower LogLevel: Msg is logged to Console
2012-08-03 14:20:18 +02:00
Santiago
c7a0378a82 Core/SAI: Added new parameter to actions 90 and 91
Allows to set and remove all possible bytes1 based on `type` parameter
You can see them listed in Unit.h for reference
2012-07-21 01:29:15 -03:00
Shauren
577d5b4fd1 Core/SmartScript: Corrected size of pointId parameter for MOVE_TO_POS SAI action 2012-07-03 16:22:14 +02:00
Shauren
ea9339b171 Core/SmartAI: Fixed SMART_ACTION_SET_RANGED_MOVEMENT parameters 2012-06-23 12:15:52 +02:00
Discover-
e190a202ca Core/CreatureAI: Implement an OnSpellClick hook instead of the ugly way that uses DoAction with EVENT_SPELLCLICK.
Core/SmartAI: Implement SMART_EVENT_ON_SPELLCLICK. Parameter is the clicker.

If someone could update the wiki accordingly for SAI I would appreciate that. Thanks to @Shauren for some help!
2012-06-19 00:07:20 +02:00
Nay
53b561f550 Core/SAI: Remove some unused conditions related code
SAI conditions were implemented in a different way than initially planned

Signed-off-by: Nay <dnpd.dd@gmail.com>
2012-06-18 00:42:37 +01:00
Nay
d61f9fb40c Fix build in GCC
Signed-off-by: Nay <dnpd.dd@gmail.com>
2012-06-17 22:11:27 +01:00
Nay
8c16cc2260 Core/SAI: Implement SMART_EVENT_ACTION_DONE (72, DoAction)
Param1 is event id
This event is triggered on spellclick (id=1001), fall on ground (id=1002) and charge (id=1003)

Signed-off-by: Nay <dnpd.dd@gmail.com>
2012-06-17 21:50:01 +01:00
Subv
38f6f9d8cb Core/SAI: Missing change from previous commit 2012-06-11 11:15:33 -05:00